SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
17.
class JavaScrap extends Person {
constructor(name) {
super(name);
this.shout('i <3 js');
}
shout(msg) {
this.say(msg.toUpperCase());
}
} ➤
18.
"My name is " + name + ".n" +
"I will be " + (age + 1) + " next year."
`My name is ${name}.
I will be ${age + 1} next year.`
Becomes
➤
19.
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.
20.
1. What is ES2015?
2. How can I use it?
3. What’s next?
29.
$ ./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
35.
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');
});
});
36.
$ ./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)
38.
$ ./node_modules/.bin/mocha --require babel/register
test index
✓ should instantiate with defaults
✓ should provide a greeting
2 passing (7ms)
39.
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