SlideShare una empresa de Scribd logo
1 de 50
Descargar para leer sin conexión
ES6
Cory Forsyth
@bantic
Cory Forsyth
@bantic
JavaScript History
JavaScript is not a
Language
• JavaScript is an implementation of a language
• ActionScript was another implementation
• The name of the language is: ECMAScript
• JavaScript : ECMAScript :: Rubinius/JRuby : Ruby
JavaScript History
• Invented at Netscape by Brendan Eich
• Mocha -> LiveScript -> JavaScript
• 1996 -> Standardization taken by Ecma
• Renamed -> ECMAScript (trademark reasons)
ECMAScript
• What is Ecma?
• “Ecma International is an industry association …
dedicated to the standardization of Information and
Communication Technology”
• Its website slogan is: “Standards@Internet Speed”
Ecma Org Chart
Ecma Org Chart
• TC = Technical Committee
• TC39 = Technical Committee tasked with
ECMAScript ®
• TC39 Official Scope: “Standardization of the
general purpose, cross platform, vendor-neutral
programming language ECMAScript.”
• Ecma = European Computer Manufacturers
Association
ECMAScript
• 1997: ECMA-262: Language Standard
• On github (now): tc39/ecma262
• 1998 ES2
• 1999 ES3
ECMAScript
• 2000: ES4
ECMAScript
• 2000: ES4
ECMAScript
• 2000: ES4
• 2005: ES4
• Mozilla and Macromedia
• Big changes, major leap from ES5
ECMAScript
• 2000: ES4
• 2005: ES4
• Mozilla and Macromedia
• Big changes, major leap from ES5
• Divisive, Yahoo & Microsoft opposed
ECMAScript
• 2000: ES4
• 2005: ES4
• Mozilla and Macromedia
• Big changes, major leap from ES5
• Divisive, Yahoo & Microsoft opposed
ES5
• 2009 in Oslo
• “Modern” JavaScript
• Originally v3.1 (incremental change)
• “Harmony”
ES6
• Will be released in 2015
• After this, versions will be released yearly:
• ES2015
• ES2016
• …
ES2015: What’s New?
ES2015
• Syntax Changes
• New features
• Fixes
• Superset of ES5
if (true) {
var x = 'yes';
}
console.log(x); // 'yes'
if (true) {
let x = 'yes';
}
console.log(x); // ReferenceError
var is hoisted
let is block scope
`let` there be light scope
hoisting
function() {
console.log(x); // undefined
var x = 'foo';
console.log(x); // ‘foo’
}
hoisting
function() {
var x;
console.log(x); // undefined
x = 'foo';
console.log(x); // ‘foo’
}
`let` : temporal dead zone
function() {
console.log(x); // ReferenceError
// TDZ
let x = 'foo';
console.log(x); // ‘foo’
}
`let` there be sanity
let funcs = [];
for (var i=0; i < 5; i++) {
funcs.push(function() { alert(i); });
}
funcs[0]();
`let` there be sanity
let funcs = [];
for (let i=0; i < 5; i++) {
funcs.push(function() { alert(i); });
}
funcs[0]();
a new i for each turn of the loop
`const`
const x = 'foo';
x = 'bar'; // error
const x = {
foo: 'bar'
};
x.foo = 'baz'; // ok (!)
can modify properties of a const
cannot reassign const
use Object.freeze, Object.seal to
prevent changes to an object
Arrow functions =>
var x = function() {} let x = () => {}
• Has own scope
• Has `arguments`
• No implicit return
• “lexical” scope
• No `arguments`
• implicit return*
• *sometimes
Arrow functions =>
this.x = 'yes';
let y = () => {
"use strict";
console.log(this.x);
};
y(); // 'yes'
this.x = 'yes';
var y = function(){
"use strict";
console.log(this.x);
};
y(); // TypeError…
`this` is undefined `this` from outer scope
No need for var that = this, `bind` with
arrow functions
Arrow functions =>
1 arg: no parens, implicit return
let square = x => x * x;
let squares = [1,2,3].map(square);
console.log(squares) // [1,4,9]
Arrow functions =>
1 arg: no parens, implicit return
let square = x => x * x;
let squares = [1,2,3].map(square);
console.log(squares) // [1,4,9]
let add = (a,b) => a + b;
add(2,3); // 5
2 args: needs parens, implicit return
Arrow functions =>
1 arg: no parens, implicit return
let square = x => x * x;
let squares = [1,2,3].map(square);
console.log(squares) // [1,4,9]
let add = (a,b) => a + b;
add(2,3); // 5
2 args: needs parens, implicit return
let add = (a,b) => { return a + b };
add(2,3); // 5
function body: use {}, explicit return
Arrow functions =>
`arguments` from outer scope
let x = function() {
return () => {
alert(arguments[0]);
};
}
let y = x(5);
y();
uses x’s arguments
template strings
string interpolation!
let foo = 'bar';
console.log(`foo = ${foo}`);
// "foo = bar"
let multiline = `first line
and second line
`);
multiline strings
destructuring assignment
let obj = {
foo: 'bar',
boo: 'baz'
};
let {foo, boo} = obj;
console.log(foo); // 'bar'
console.log(boo); // 'baz'
let colors = ['red', 'green'];
let [color1, color2] = colors;
console.log(color2); // green
for objects
for arrays
destructuring assignment
mixed
let obj = {
foo: 'bar',
colors: ['red', 'green']
}
let {foo, colors: [color1, color2]} = obj;
console.log(foo); // bar
console.log(color2); // green
shorthand object assignment
same property and
variable name
let foo = 'bar';
let obj = {
foo,
boo() {
console.log('baz');
}
}
console.log(obj.foo); // bar
obj.boo(); // baz
function without
“: function”
default function params
function doSomething(timeout, options) {
timeout = timeout || 2000;
options = options || {repeat: true};
var repeat = options.repeat;
setTimeout(function(){
console.log(repeat);
}, timeout);
}
doSomething(0);
// logs 'true' after 2000ms
ES5
default function params
function doSomething(timeout=2000, {repeat}={repeat:true}) {
setTimeout(function(){
console.log(repeat);
}, timeout);
}
doSomething(0);
// logs "true" right away
ES6
function rest params
function sum(first, ...others) {
let sum = first;
for (let i of others) {
sum = sum + i;
}
console.log(sum);
}
sum(1, 2, 3, 4); // 10
others is an array of remaining args
spread operator
function sum2(first, ...others) {
console.log(sum + Math.max(...others));
}
sum2(1, 2, 4, 3); // 5 (=== 1 + 4)
Math.max(…others)
is equivalent to Math.max(2,4,3)
classes
class Person {
constructor() {
this.name = 'Cory';
}
sayHi() {
console.log(this.name);
}
}
let p = new Person();
p.sayHi(); // Cory
extend and super also work as expected
modules
named export
// file a.js
export let x = ‘yes';
export default {
foo: 'bar'
};
// file b.js
import { x } from 'a';
console.log(x); // yes
import stuff from 'a';
console.log(stuff.foo); // bar
named import
default export
default import
Other ES2015 features
• Object.is() — fixes == and ===
• Unicode support
• Promises for async support
• Symbols — a new primitive
• iterators and generators
• Map, Set
• Object.assign() — aka `extend`, `merge` or `mixin`
• String methods — `includes`, `repeat`, `startsWith`
• function.name
• … many more
What’s the status today?
How do I use it?
Babel support
• Many ES2015 (aka ES6) features and syntax
• Some ES2016 (aka ES7) features and syntax
• Some things transpiled directly to ES5
• Some supported via Polyfill
• Some not supported yet (Proxies, in particular)
The JavaScript Future
• Transpiling
• Not just a transitionary thing
• Support matrices
• ES is a living standard
• Venn Diagram of ES2015 / ES2016 / Browser Support
• As target browsers support features your code uses, turn off transpilation of
those features
Cory Forsyth
@bantic
Thank you!
• Babel and Babel REPL
• Using ES6 Today
• ES6 Glossary
• ES6+ Compatibility Table
• ES6 Overview Slides
• ECMA-262 Living Standard on github
• Ecma International
• ES6 Learning
• Aligning Ember With Web Standards
• http://bit.ly/bantic-es6 — these slides
Links

Más contenido relacionado

La actualidad más candente

HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
Giordano Scalzo
 

La actualidad más candente (20)

EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
 
ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Javascript ES6 generators
Javascript ES6 generatorsJavascript ES6 generators
Javascript ES6 generators
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScript
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancement
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
 
Metaprogramming and Reflection in Common Lisp
Metaprogramming and Reflection in Common LispMetaprogramming and Reflection in Common Lisp
Metaprogramming and Reflection in Common Lisp
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 

Destacado

Destacado (20)

ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern JavascriptES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern Javascript
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
Lecture 2: ES6 / ES2015 Slide
Lecture 2: ES6 / ES2015 SlideLecture 2: ES6 / ES2015 Slide
Lecture 2: ES6 / ES2015 Slide
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
JavaScript 快速複習 2017Q1
JavaScript 快速複習 2017Q1JavaScript 快速複習 2017Q1
JavaScript 快速複習 2017Q1
 
Workshop de Web Components
Workshop de Web ComponentsWorkshop de Web Components
Workshop de Web Components
 
Material design
Material designMaterial design
Material design
 
WebApps com Web Components
WebApps com Web ComponentsWebApps com Web Components
WebApps com Web Components
 
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
 
Um salve para evolução! construindo uma nova web com polymer
Um salve para evolução! construindo uma nova web com  polymerUm salve para evolução! construindo uma nova web com  polymer
Um salve para evolução! construindo uma nova web com polymer
 
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
 
The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015The Beautiful Simplicity of ES2015
The Beautiful Simplicity of ES2015
 
Tech talk polymer
Tech talk polymerTech talk polymer
Tech talk polymer
 
Polymer Starter Kit
Polymer Starter KitPolymer Starter Kit
Polymer Starter Kit
 
Polymer Elements: Tudo que você precisa saber para criar a web
Polymer Elements: Tudo que você precisa saber para criar a webPolymer Elements: Tudo que você precisa saber para criar a web
Polymer Elements: Tudo que você precisa saber para criar a web
 
Apresentação Google I/O Extended Vitória
Apresentação Google I/O Extended VitóriaApresentação Google I/O Extended Vitória
Apresentação Google I/O Extended Vitória
 
Web components
Web componentsWeb components
Web components
 
Material Design - do smartphone ao desktop
Material Design - do smartphone ao desktopMaterial Design - do smartphone ao desktop
Material Design - do smartphone ao desktop
 
Polymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in RealtimePolymer and Firebase: Componentizing the Web in Realtime
Polymer and Firebase: Componentizing the Web in Realtime
 

Similar a Explaining ES6: JavaScript History and What is to Come

Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 
Rust-lang
Rust-langRust-lang
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
qmmr
 

Similar a Explaining ES6: JavaScript History and What is to Come (20)

Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Javascript
JavascriptJavascript
Javascript
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
What's New in ES6 for Web Devs
What's New in ES6 for Web DevsWhat's New in ES6 for Web Devs
What's New in ES6 for Web Devs
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
 
AkJS Meetup - ES6++
AkJS Meetup -  ES6++AkJS Meetup -  ES6++
AkJS Meetup - ES6++
 
Rust-lang
Rust-langRust-lang
Rust-lang
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
Ignite es6
Ignite es6Ignite es6
Ignite es6
 

Más de Cory Forsyth

Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for Everybody
Cory Forsyth
 
Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014
Cory Forsyth
 

Más de Cory Forsyth (12)

EmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning TalkEmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning Talk
 
Making ember-wormhole work with Fastboot
Making ember-wormhole work with FastbootMaking ember-wormhole work with Fastboot
Making ember-wormhole work with Fastboot
 
Chrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JSChrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JS
 
OAuth 2.0 Misconceptions
OAuth 2.0 MisconceptionsOAuth 2.0 Misconceptions
OAuth 2.0 Misconceptions
 
Ember Authentication and Authorization with Torii
Ember Authentication and Authorization with ToriiEmber Authentication and Authorization with Torii
Ember Authentication and Authorization with Torii
 
HAL APIs and Ember Data
HAL APIs and Ember DataHAL APIs and Ember Data
HAL APIs and Ember Data
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
 
Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for Everybody
 
Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014
 
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
 
Torii: Ember.js Authentication Library
Torii: Ember.js Authentication LibraryTorii: Ember.js Authentication Library
Torii: Ember.js Authentication Library
 
APIs: Internet for Robots
APIs: Internet for RobotsAPIs: Internet for Robots
APIs: Internet for Robots
 

Último

pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Monica Sydney
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Monica Sydney
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
galaxypingy
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
ydyuyu
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 

Último (20)

pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 

Explaining ES6: JavaScript History and What is to Come

  • 4. JavaScript is not a Language • JavaScript is an implementation of a language • ActionScript was another implementation • The name of the language is: ECMAScript • JavaScript : ECMAScript :: Rubinius/JRuby : Ruby
  • 5. JavaScript History • Invented at Netscape by Brendan Eich • Mocha -> LiveScript -> JavaScript • 1996 -> Standardization taken by Ecma • Renamed -> ECMAScript (trademark reasons)
  • 6. ECMAScript • What is Ecma? • “Ecma International is an industry association … dedicated to the standardization of Information and Communication Technology” • Its website slogan is: “Standards@Internet Speed”
  • 7.
  • 9. Ecma Org Chart • TC = Technical Committee • TC39 = Technical Committee tasked with ECMAScript ® • TC39 Official Scope: “Standardization of the general purpose, cross platform, vendor-neutral programming language ECMAScript.” • Ecma = European Computer Manufacturers Association
  • 10. ECMAScript • 1997: ECMA-262: Language Standard • On github (now): tc39/ecma262 • 1998 ES2 • 1999 ES3
  • 13. ECMAScript • 2000: ES4 • 2005: ES4 • Mozilla and Macromedia • Big changes, major leap from ES5
  • 14. ECMAScript • 2000: ES4 • 2005: ES4 • Mozilla and Macromedia • Big changes, major leap from ES5 • Divisive, Yahoo & Microsoft opposed
  • 15. ECMAScript • 2000: ES4 • 2005: ES4 • Mozilla and Macromedia • Big changes, major leap from ES5 • Divisive, Yahoo & Microsoft opposed
  • 16. ES5 • 2009 in Oslo • “Modern” JavaScript • Originally v3.1 (incremental change) • “Harmony”
  • 17. ES6 • Will be released in 2015 • After this, versions will be released yearly: • ES2015 • ES2016 • …
  • 19. ES2015 • Syntax Changes • New features • Fixes • Superset of ES5
  • 20. if (true) { var x = 'yes'; } console.log(x); // 'yes' if (true) { let x = 'yes'; } console.log(x); // ReferenceError var is hoisted let is block scope `let` there be light scope
  • 21. hoisting function() { console.log(x); // undefined var x = 'foo'; console.log(x); // ‘foo’ }
  • 22. hoisting function() { var x; console.log(x); // undefined x = 'foo'; console.log(x); // ‘foo’ }
  • 23. `let` : temporal dead zone function() { console.log(x); // ReferenceError // TDZ let x = 'foo'; console.log(x); // ‘foo’ }
  • 24. `let` there be sanity let funcs = []; for (var i=0; i < 5; i++) { funcs.push(function() { alert(i); }); } funcs[0]();
  • 25. `let` there be sanity let funcs = []; for (let i=0; i < 5; i++) { funcs.push(function() { alert(i); }); } funcs[0](); a new i for each turn of the loop
  • 26. `const` const x = 'foo'; x = 'bar'; // error const x = { foo: 'bar' }; x.foo = 'baz'; // ok (!) can modify properties of a const cannot reassign const use Object.freeze, Object.seal to prevent changes to an object
  • 27. Arrow functions => var x = function() {} let x = () => {} • Has own scope • Has `arguments` • No implicit return • “lexical” scope • No `arguments` • implicit return* • *sometimes
  • 28. Arrow functions => this.x = 'yes'; let y = () => { "use strict"; console.log(this.x); }; y(); // 'yes' this.x = 'yes'; var y = function(){ "use strict"; console.log(this.x); }; y(); // TypeError… `this` is undefined `this` from outer scope No need for var that = this, `bind` with arrow functions
  • 29. Arrow functions => 1 arg: no parens, implicit return let square = x => x * x; let squares = [1,2,3].map(square); console.log(squares) // [1,4,9]
  • 30. Arrow functions => 1 arg: no parens, implicit return let square = x => x * x; let squares = [1,2,3].map(square); console.log(squares) // [1,4,9] let add = (a,b) => a + b; add(2,3); // 5 2 args: needs parens, implicit return
  • 31. Arrow functions => 1 arg: no parens, implicit return let square = x => x * x; let squares = [1,2,3].map(square); console.log(squares) // [1,4,9] let add = (a,b) => a + b; add(2,3); // 5 2 args: needs parens, implicit return let add = (a,b) => { return a + b }; add(2,3); // 5 function body: use {}, explicit return
  • 32. Arrow functions => `arguments` from outer scope let x = function() { return () => { alert(arguments[0]); }; } let y = x(5); y(); uses x’s arguments
  • 33. template strings string interpolation! let foo = 'bar'; console.log(`foo = ${foo}`); // "foo = bar" let multiline = `first line and second line `); multiline strings
  • 34. destructuring assignment let obj = { foo: 'bar', boo: 'baz' }; let {foo, boo} = obj; console.log(foo); // 'bar' console.log(boo); // 'baz' let colors = ['red', 'green']; let [color1, color2] = colors; console.log(color2); // green for objects for arrays
  • 35. destructuring assignment mixed let obj = { foo: 'bar', colors: ['red', 'green'] } let {foo, colors: [color1, color2]} = obj; console.log(foo); // bar console.log(color2); // green
  • 36. shorthand object assignment same property and variable name let foo = 'bar'; let obj = { foo, boo() { console.log('baz'); } } console.log(obj.foo); // bar obj.boo(); // baz function without “: function”
  • 37. default function params function doSomething(timeout, options) { timeout = timeout || 2000; options = options || {repeat: true}; var repeat = options.repeat; setTimeout(function(){ console.log(repeat); }, timeout); } doSomething(0); // logs 'true' after 2000ms ES5
  • 38. default function params function doSomething(timeout=2000, {repeat}={repeat:true}) { setTimeout(function(){ console.log(repeat); }, timeout); } doSomething(0); // logs "true" right away ES6
  • 39. function rest params function sum(first, ...others) { let sum = first; for (let i of others) { sum = sum + i; } console.log(sum); } sum(1, 2, 3, 4); // 10 others is an array of remaining args
  • 40. spread operator function sum2(first, ...others) { console.log(sum + Math.max(...others)); } sum2(1, 2, 4, 3); // 5 (=== 1 + 4) Math.max(…others) is equivalent to Math.max(2,4,3)
  • 41. classes class Person { constructor() { this.name = 'Cory'; } sayHi() { console.log(this.name); } } let p = new Person(); p.sayHi(); // Cory extend and super also work as expected
  • 42. modules named export // file a.js export let x = ‘yes'; export default { foo: 'bar' }; // file b.js import { x } from 'a'; console.log(x); // yes import stuff from 'a'; console.log(stuff.foo); // bar named import default export default import
  • 43. Other ES2015 features • Object.is() — fixes == and === • Unicode support • Promises for async support • Symbols — a new primitive • iterators and generators • Map, Set • Object.assign() — aka `extend`, `merge` or `mixin` • String methods — `includes`, `repeat`, `startsWith` • function.name • … many more
  • 45.
  • 46. How do I use it?
  • 47.
  • 48. Babel support • Many ES2015 (aka ES6) features and syntax • Some ES2016 (aka ES7) features and syntax • Some things transpiled directly to ES5 • Some supported via Polyfill • Some not supported yet (Proxies, in particular)
  • 49. The JavaScript Future • Transpiling • Not just a transitionary thing • Support matrices • ES is a living standard • Venn Diagram of ES2015 / ES2016 / Browser Support • As target browsers support features your code uses, turn off transpilation of those features
  • 50. Cory Forsyth @bantic Thank you! • Babel and Babel REPL • Using ES6 Today • ES6 Glossary • ES6+ Compatibility Table • ES6 Overview Slides • ECMA-262 Living Standard on github • Ecma International • ES6 Learning • Aligning Ember With Web Standards • http://bit.ly/bantic-es6 — these slides Links