Skip to content

Instantly share code, notes, and snippets.

@tjFogarty
Created September 30, 2014 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjFogarty/ffc9655ac9dda20838a2 to your computer and use it in GitHub Desktop.
Save tjFogarty/ffc9655ac9dda20838a2 to your computer and use it in GitHub Desktop.
ES6
/* 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'));
});
<!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>
'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