Created
September 30, 2014 14:13
-
-
Save tjFogarty/ffc9655ac9dda20838a2 to your computer and use it in GitHub Desktop.
ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint node:true */ | |
'use strict'; | |
var gulp = require('gulp'); | |
var traceur = require('gulp-traceur'); | |
gulp.task('scripts', function () { | |
return gulp.src('js/main.js') | |
.pipe(traceur()) | |
.pipe(gulp.dest('js/dist')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>ES6 Test</title> | |
<script src="node_modules/gulp-traceur/node_modules/traceur/bin/traceur-runtime.js"></script> | |
<style> | |
html { | |
font-family: sans-serif; | |
} | |
</style> | |
</head> | |
<body> | |
<h1 class="greeting"></h1> | |
<script src="js/dist/main.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class Greeter { | |
constructor(name) { | |
this.name = name; | |
} | |
sayHi() { | |
console.log('Hi, ' + this.name); | |
} | |
} | |
class Insulter extends Greeter { | |
constructor(name, slag) { | |
super(name); | |
this.slag = slag; | |
this.greetingContainer = document.querySelectorAll('.greeting')[0]; | |
} | |
insult() { | |
this.greetingContainer.innerHTML = 'Hi, ' + this.name + '. You\'re some ' + this.slag + '.'; | |
} | |
} | |
var greeter = new Insulter('TJ', 'fool'); | |
greeter.insult(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment