What's New in ECMAScript 2015

31
What’s New in ECMAScript 2015 Sasha dos Santos @sashageekette Orlando Code Camp 2016

Transcript of What's New in ECMAScript 2015

Page 1: What's New in ECMAScript 2015

What’s New in ECMAScript 2015

Sasha dos Santos@sashageekette

Orlando Code Camp 2016

Page 2: What's New in ECMAScript 2015

Class

https://jsfiddle.net/87mp3gk5/2/

Page 3: What's New in ECMAScript 2015

Inheritance

https://jsfiddle.net/t56f2afg/3/

Page 4: What's New in ECMAScript 2015

Static Methods

https://jsfiddle.net/boLg6oc1/2/

Page 5: What's New in ECMAScript 2015

Default Parameters

https://jsfiddle.net/67r879tn/2/

Page 6: What's New in ECMAScript 2015

Arrow Functions - ex. 1

https://jsfiddle.net/powsc8u7/5/

Page 7: What's New in ECMAScript 2015

Arrow Functions - ex. 2

https://jsfiddle.net/7091rwru/7/

Page 8: What's New in ECMAScript 2015

Template Literals

https://jsfiddle.net/75uktrxn/2/

Page 9: What's New in ECMAScript 2015

Spread Operator

https://jsfiddle.net/xLbhq1xe/21/

Page 10: What's New in ECMAScript 2015

Object Literals

https://jsfiddle.net/wxhuL1gx/7/

Page 11: What's New in ECMAScript 2015

Destructuring Assignment - ex. 1

https://jsfiddle.net/9g06bgdx/2/

Page 12: What's New in ECMAScript 2015

Destructuring Assignment - ex. 2

https://jsfiddle.net/9g06bgdx/25/

Page 13: What's New in ECMAScript 2015

let

https://jsfiddle.net/cys2eg3s/1/

Page 14: What's New in ECMAScript 2015

const

https://jsfiddle.net/96svxzpa/4/

Page 15: What's New in ECMAScript 2015

Object.assign

https://jsfiddle.net/b4zmquxt/6/

Page 16: What's New in ECMAScript 2015

Iterators & Generators

https://jsfiddle.net/e7ea9vj3/24/

Page 17: What's New in ECMAScript 2015

for…of

https://jsfiddle.net/v4q42oca/21/

Page 18: What's New in ECMAScript 2015

Set

https://jsfiddle.net/cgfvyk44/22/

Page 19: What's New in ECMAScript 2015

WeakMap

https://jsfiddle.net/oqLuaj7q/22/

Page 20: What's New in ECMAScript 2015

Symbols

https://jsfiddle.net/995Lk2qp/5/

Page 21: What's New in ECMAScript 2015

Modules

Page 22: What's New in ECMAScript 2015

Backwards Compatibility

• No browser implements all of these new features

• To check compatibility:• CanIUse.com• http://kangax.github.io/compat-table/es

6/• MDN (mozilla developer network)

Page 24: What's New in ECMAScript 2015

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol

Page 25: What's New in ECMAScript 2015

JavaScript Transpilers• Compiler that translates between languages• ES6 -> ES5• Write code now in ES6, but browser

executes ES5 equivalent• Babel https://babeljs.io/• Traceur

https://github.com/google/traceur-compiler

Page 26: What's New in ECMAScript 2015
Page 27: What's New in ECMAScript 2015

Babel• Not recommended that you try to transpile

‘on the fly’ at the client, though its possible (https://cdnjs.com/libraries/babel-core)

• Option 1: Manually transpile code before publish

• Better Option 2: Integrate with you existing build tool such as Browserify, Webpack, Gulp, MSBuild, etc (babeljs.io/docs/setup)

Page 28: What's New in ECMAScript 2015

Module Bundling• Webpack and Browserify are popular JS

bundling tools, but they support CommonJS modules and not the new ES6 imports

• Combine with Babel which will convert your import statements into require statements

• ex. Browserify + Babelify = use imports and bundle

Page 29: What's New in ECMAScript 2015

Polyfills• Code that provides ‘native’ functionality

that isn’t actually supported by the browser.

• You code using ES6 and if not natively supported, the polyfill code is executed.

• Transpilers can rewrite code to ES5, but may still require polyfills for calls that have no ES5 equivalent

Page 30: What's New in ECMAScript 2015

Polyfills (continued)• To look for

specific polyfills to copy into your project, go to MDN and search for feature

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

Page 31: What's New in ECMAScript 2015

Polyfills (continued)

• There are plenty of libraries (modules) that provide many polyfills and you can import only the ones you need (consult the google)

• ex. https://github.com/es-shims