class JavaScrap extends Person {
constructor(name) {
super(name);
this.shout('i <3 js');
}
shout(msg) {
this.say(msg.toUpperCase());
}
} ➤
"My name is " + name + ".n" +
"I will be " + (age + 1) + " next year."
`My name is ${name}.
I will be ${age + 1} next year.`
Becomes
➤
RESOURCE SLIDE!
Exploring ES6 by @rauschma : http://exploringjs.com/ (online)
Six steps for approaching ES6, telerik : Six Steps for approaching ES6
ES6 in depth : https://hacks.mozilla.org/category/es6-in-depth/
ES6 Features : https://github.com/lukehoban/es6features
ES6 console : http://jsoverson.github.io/es6repl/
Babel repl : https://babeljs.io/repl/
ES6 features (dot org) : http://es6-features.org/
ES6 compatibility : https://kangax.github.io/compat-table/es6/
You Don’t Know JS : ES6 & Beyond by @getify
Learning ES2015 would be impossible in 20 minutes. This talk is about getting stuff done.
1. What is ES2015?
2. How can I use it?
3. What’s next?
$ ./node_modules/.bin/eslint —-init
? What style of indentation do you use? Spaces
? What quotes do you use for strings? Single
? What line endings do you use? Unix
? Do you require semicolons? Yes
? Are you using ECMAScript 6 features? Yes
? Where will your code run? Node, Browser
? Do you use JSX? No
? What format do you want your config file to be in? JSON
Successfully created .eslintrc file in ./es6-linting
import assert from 'assert';
import Greeter from '../src/';
describe('test index', () => {
let greeter;
before(() => {
greeter = new Greeter();
});
it('should instantiate with defaults', () => {
assert.equal(greeter.greeting, 'Hello');
assert.equal(greeter.target, 'World');
});
it('should provide a greeting', () => {
var greeting = greeter.getGreeting();
assert.equal(greeting, 'Hello World');
});
});
$ ./node_modules/.bin/mocha test/
test/index.spec.js:2
import assert from 'assert';
^^^^^^
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Enables you to run :
package.json :
"scripts": {
"unit": "mocha --require babel/register”,
"test": "$npm_package_scripts_lint && $npm_package_scripts_unit"
},
$ npm run unit
$ npm run test
$ npm test “test” is a special, first-class script
Note: npm script values as variables