SlideShare a Scribd company logo
Sebastiano Armeli
@sebarmeli
http://courtreportingnyc.com/wp-content/uploads/2013/10/future-of-court-reporting.jpg
@sebarmeli
Sebastiano Armeli
ES6
History
1995	

 1996	

 1997	

 1998	

 1999	

 2000	

 2003	

(May) B. Eich invented Mocha
(Dec) LiveScript renamed to JavaScript
JSScript
(June) ECMA-262 Ed.1!
! by TC39 committee
ECMA-262 Ed.2
ECMA-262 Ed.3
ECMA-262 Ed.4 started
ECMA-262 Ed.4 abandoned
(Sep) Mocha renamed to LiveScript
History
2005	

 2007	

 2008	

 2009	

 2011	

 2013	

2014	

ES 4 again!
(Adobe, Mozilla,!
Google)!
ES 3.1 !
(Microsoft, Yahoo)!
beginning
ES 5 spec finalized
(June) ECMA-262 Ed.5
(June) ES 6
proposals freeze
(Dec) ECMA-262 Ed.6 target release
(27th April) latest spec draft
(July) Agreement: ES3.1 & ES-Harmony!
!
ES3.1 becomes ES5
ECMA-262
TC39
ES 4
ES-Harmony
ES.Next
ES 6
ECMA
ES 7
es-discuss
ES-Harmony Proposal
ES 6 Candidate
ECMA-262 Ed.6 standardized
ES 6 Specification Draft
TC39 Process
Strawman
Proposal
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
(Fat) arrow function
var y = (x) => x + 1 var y = function(x) {
return x + 1;
}
ES6 ES5
(Fat) arrow function
var y = (x) => x + 1 var y = function(x) {
return x + 1;
}
ES6 ES5
No constructor	

Syntax sugar 	

Lexical `this` binding
(Fat) arrow function
var y = (x) => x + 1 var y = function(x) {
return x + 1;
}
ES6 ES5
No constructor	

Syntax sugar 	

Lexical `this` binding
(Fat) arrow function
var y = (x) => x + 1 var y = function(x) {
return x + 1;
}
ES6 ES5
No constructor	

Syntax sugar 	

Lexical `this` binding
let x = (x) =>
{return x + 1}
var x = function(x) {
return x + 1;
}
let x = (x, y) =>
({
x: x,
y: y
})
var x = function(x, y) {
return {
x: x,
y: y
};
}
ES6 ES5
let map = words =>
words.map((w) => w.length);
var map = function(words) {
return words.map(function(w) {
return w.length;
}
}
ES6
ES5
map([‘sea’, ‘beach’, ‘do’]); // [3,5,2]
var obj = {
doIt: function(){},
handle: function(){
document.addEventListener(‘click’, function(e) {
this.doIt();
}.bind(this));
}
}
ES5
var obj = {
doIt: function(){},
handle: function(){
var that = this;
document.addEventListener(‘click’, function(e) {
that.doIt();
});
}
}
ES3
var obj = {
doIt: function(){},
handle: function(){
document.addEventListener(‘click’,
(e) => this.doIt());
}
}
ES6
Object.getPrototypeOf(() => {})
Object.getPrototypeOf(() => {})
Function.prototype
When to use
‘function’ ?
Constructors	

Generators	

Methods in obj
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping & Calling	

API improvements	

Proxies
Block Scoping
Each BLOCK has got its lexical environment	

let/const bind variables to the lexical environment	

Variables declared with let/const are NOT hoisted
var vs let
(function() {
console.log(y) // “undefined”
if (true) {
var y = “value”;
}
console.log(y) // “value”
}());
var vs let
(function() {
if (true) {
let y = “value”;
}
console.log(y) // ERROR!!
}());
(function() {
console.log(y) // “undefined”
if (true) {
var y = “value”;
}
console.log(y) // “value”
}());
const
(function() {
const X;
X = “foo”; // ERROR: x unitialized
}());
(function() {
const X = “foo”;
X = “foo2”; // ERROR: x is read-only
}());
Block functions
if (true) {
function fn () {}
}
!
fn(); // ERROR!
Destructing array
var [x,y] = [‘a’, ‘b’];
!
console.log(x); // ‘a’
!
console.log(y); // ‘b’
!
!
var [x,y] = [y, x];
!
console.log(x); // ‘b’
Destructing object
var obj = {width: 50, height: 100};
!
var {width, height} = obj;
!
console.log(width); // 50
Destructing
multiple return value
var fn = function(){
return [“50”, “100”];
}
!
var [width, height] = fn();
!
console.log(width); //50
console.log(height); //100
Default values
function(foo) {
foo = foo || “a”;
}
Default values
function(foo) {
foo = foo || “a”;
}
function(foo = “a”) {}
function fn(…args) {
console.log(args); //[“a”, “b”, “c”]
args.forEach(function(arg) {
console.log(arg);
};
}
!
fn(“a”, “b”, “c”);
!
// a
// b
// c
Rest parameters
Rest parameters
function fn(a, …args) {
console.log(args); //[“b”, “c”]
args.forEach(function(arg) {
console.log(arg);
};
}
!
fn(“a”, “b”, “c”);
!
// b
// c
Spread operator
function fn(a, b, c) {}
!
var array = [“A”, “B”, “C”];
fn.apply(null, array);
function fn(a, b, c) {}
!
var array = [“A”, “B”, “C”];
fn.apply(null, array);
fn(…array);
Spread operator
function fn(a, b, c) {
var array = Array.prototype.
slice.apply(arguments);
}
Spread operator
function fn(a, b, c) {
var array = Array.prototype.
slice.apply(arguments);
var array = […arguments];
}
Spread operator
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
for-of
for-of loop on ‘iterables’	

Arrays/Sets/Maps are ’iterables’	

for-in limitations
Iterable
{ iterator: function() -> iterator }
{ next: function() -> any }
Iterators
for-of
var array = [“a”, “b”, “c”];
!
for (let el of array) {
console.log(el);
}
!
// “a”
// “b”
// “c”
Array comprehension
var array = [1, 2, 11, 20];
!
var array_c = [x (for x of
array) (if x > 10)];
!
// [11, 20]
function* g() {
yield “a”;
yield “b”;
}
Generator
var generator = g();
generator ‘constructor’	

generator.next(); //{ value: “a”, done: false}
generator.next(); //{ value: “b”, done: false}
generator.next(); //{ value: undefined,
done: true}
!
function* g() {
yield “a”;
var retVal = yield “b”;
return retVal;
}
var generator = g();
generator.next().value; //“a”
generator.next().value; //“b”
generator.next(“c”).value; //“c”
!
function* asyncFn() {
var data = yield getUser();
doSomethingElse(data);
}
function run(genFunction) {
var generator = genFunction();
generator.next().value.then(function(val){
generator.next(val);
}, function(err) {
generator.throw(err);
});
}
run(asyncFn);
Promise
for (let el of generator) {
console.log(el);
}
Generators are iterables
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
Set
Set of values - NO duplicates	

Different type of values	

add(key)/ has(key) / delete(key)
entries() -> Iterator
let countries = new Set();
countries.add(“US”);
countries.add(“Italy”);
countries.add(“US”);
!
countries.values().next().value;
// “US”
!
countries.values().next().value;
// “Italy”
!
for(let country of countries) {
console.log(country);
}
Map
key-value	

Different type of values	

Object can be keys	

get(key)/ has(key) / set(key,val)
let dict = new Map();
dict.set(“A”, 1);
dict.set(“B”, 2);
!
dict.get(“A”); // “1”
dict.delete(“B”);
!
for(let w of dict.keys()) {
console.log(w); // “A”
}
!
for(let w of dict.values()) {
console.log(w); // “A”
}
WeakMap
Avoid memory leaks	

Reference to the key obj held weakly	

Key must be an object	

No iterators methods
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
Module
!
module “ads” {
export function register(ad) {
return ad;
}
}
!
import {register} from “ads”;
var app = {
doIt: function() {
register({});
}
}
export app;
app.js
lib/ads.js
!
module “widget” {…}
module “widget/button” {…}
module “widget/text” {…}
!
!
import ‘lib/ad’ as c;
import { meth as method } from ‘a';
!
!
export default class {}; // Ad.js
import Ad from ‘ad'; // app.js
Loader API
System.load('http://json.org/modules/json2.js',
function(JSON) {
alert(JSON.stringify([0, {a: true}]));
});
System.import
Configure module loading
Class / Subclass!
class Animal {
constructor(name) {
this.name = name;
}
toString() {
return “This is: ” + this.name;
}
}
class Cat extends Animal {
constructor(name, ownerName) {
super.constructor(name);
this.ownerName = ownerName;
}
!
toString() {
return super.toString() + “ owned by ” +
this.ownerName;
}
}
!
function Animal(name) {
this.name = name;
}
!
Animal.prototype.toString = function() {
return “This is: ” + this.name;
};
!
function Cat(name, ownerName) {
Animal.call(this, name);
this.ownerName = ownerName;
}
!
Cat.prototype = Object.create(Animal.prototype);
Cat.prototype.constructor = Cat;
Cat.prototype.parent = Animal;
!
Cat.prototype.toString = function() {
return Animal.prototype.toString.call(this) + “ owned by ”
+ this.ownerName;
}
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
String methods
startsWith()
endsWith()
contains()
…
Number methods
Number.isInteger(num)
Number.isNaN(num)
Number.isFinite(num)
…
Array methods
var divs = document.querySelectorAll("div");
Array.from(divs);
!
// [<div></div>, </div></div>]
!
Array.of(10, 11);
!
// [10, 11]
!
!
var array = [“a”, “b”, “c”];
!
for (let [index, el] of array.entries()) {
console.log(index, el); // 0 “a”
// 1 “b”
// 2 “c”
}
!
for (let index of array.keys()) {
console.log(index);
}
!
for (let el of array.values()) {
console.log(el);
}
!
Object methods
Object.setPrototypeOf(obj, proto)
Object.assign(obj, mixin)
Object.is(value1, value2)
var object = {
method() {
return “a”;
}
}
object.method(); // “a”
!
var object = {
method() {
return “a”;
}
}
object.method(); // “a”
!
function f(x, y) { return {x: x, y: y};}
function f(x, y) { return {x, y}; }
=
Math methods
Math.log2()
Math.log10()
Math.sinh()
Math.cosh()
…
Generators & Iteration	

Summary
Functions	

Collections	

Modularity	

Scoping	

API improvements	

Proxies
Proxies
var obj = {num: 1};
!
obj = Proxy(obj, {
set: function (target, property, value) {
target[property] = value + 1;
}
});
!
obj.num = 2 // [[Set]]
console.log(obj.num); // 3
Proxies
function createDefensiveObject(target) {
return new Proxy(target, {
get: function(target, property) {
if (property in target) {
return target[property];
} else {
throw new ReferenceError();
}
}
});
}
!
var obj = createDefensiveObject({name: “Seb”});
console.log(obj.lastname); //ReferenceError
http://www.nczonline.net/blog/2014/04/22/creating-defensive-objects-with-es6-proxies/
Generators & Iteration	

Recap
Functions	

Collections	

Modularity	

Scoping / Calling	

API improvements	

Proxies
Promises	

Symbols	

Generator Expressions	

Quasi-literals (template-strings)
Tools
Traceur compiler (Google)	

es6-transpiler	

es6-module-transpiler (Square)	

es6-shim	

defs.js
http://wiki.ecmascript.org/doku.php
https://people.mozilla.org/~jorendorff/es6-draft.html
http://kangax.github.io/compat-table/es6/
http://esdiscuss.org/
@sebarmeli
Sebastiano Armeli

More Related Content

PDF
ECMAScript 6
PDF
ES2015 (ES6) Overview
PDF
An Intro To ES6
PDF
Explaining ES6: JavaScript History and What is to Come
PDF
ES6 - Next Generation Javascript
PDF
JavaScript - new features in ECMAScript 6
PDF
Introduction into ES6 JavaScript.
PPTX
ES6 in Real Life
ECMAScript 6
ES2015 (ES6) Overview
An Intro To ES6
Explaining ES6: JavaScript History and What is to Come
ES6 - Next Generation Javascript
JavaScript - new features in ECMAScript 6
Introduction into ES6 JavaScript.
ES6 in Real Life

What's hot (20)

PPTX
Introduction to Ecmascript - ES6
ODP
ES6 PPT FOR 2016
ODP
EcmaScript 6
PPTX
Modern JS with ES6
PPT
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
PDF
JavaScript ES6
PPTX
ES6: Features + Rails
PPTX
Async Frontiers
PDF
Javascript ES6 generators
PDF
What's New in ES6 for Web Devs
PDF
Proxies are Awesome!
PDF
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PDF
Planet-HTML5-Game-Engine Javascript Performance Enhancement
PDF
How to Clone Flappy Bird in Swift
PDF
Letswift19-clean-architecture
PPTX
The Promised Land (in Angular)
PDF
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
PDF
Minimizing Decision Fatigue to Improve Team Productivity
PPTX
ES6 Overview
Introduction to Ecmascript - ES6
ES6 PPT FOR 2016
EcmaScript 6
Modern JS with ES6
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
JavaScript ES6
ES6: Features + Rails
Async Frontiers
Javascript ES6 generators
What's New in ES6 for Web Devs
Proxies are Awesome!
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Planet-HTML5-Game-Engine Javascript Performance Enhancement
How to Clone Flappy Bird in Swift
Letswift19-clean-architecture
The Promised Land (in Angular)
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Minimizing Decision Fatigue to Improve Team Productivity
ES6 Overview
Ad

Viewers also liked (20)

PPTX
A walkthrough of JavaScript ES6 features
PPTX
Webinář: Ovládněte umění správy dokumentů ve vaší organizaci
PDF
ES2015 and Beyond
PPSX
BMD 5 opdracht 2
PPSX
Bmd opdracht 2
PPT
Tutorial: How to work with app “3D Molecules Edit & Test”
PPT
Halloween info
PPSX
Bmd opdracht 3 huis2
PPSX
BMD opdracht 1
PPT
E learning-2004
KEY
Backbone.js in a real-life application
PPT
vAcademia 2015
PPT
Icalt2002 2
DOC
Timetable daniela huber
PPSX
Build my dream 4 opdracht 02 deel 1/2
PDF
Valentine s day_leitner
PPSX
Summit 17 04
PPT
A walkthrough of JavaScript ES6 features
Webinář: Ovládněte umění správy dokumentů ve vaší organizaci
ES2015 and Beyond
BMD 5 opdracht 2
Bmd opdracht 2
Tutorial: How to work with app “3D Molecules Edit & Test”
Halloween info
Bmd opdracht 3 huis2
BMD opdracht 1
E learning-2004
Backbone.js in a real-life application
vAcademia 2015
Icalt2002 2
Timetable daniela huber
Build my dream 4 opdracht 02 deel 1/2
Valentine s day_leitner
Summit 17 04
Ad

Similar to EcmaScript 6 - The future is here (20)

PDF
ES6: The future is now
PDF
JavaScript in 2016
PPTX
JavaScript in 2016 (Codemotion Rome)
PPTX
Awesomeness of JavaScript…almost
PDF
Workshop 10: ECMAScript 6
PPTX
Academy PRO: ES2015
PDF
ECMAScript 6
KEY
JavaScript Growing Up
PDF
Fitc whats new in es6 for web devs
PPTX
ECMAScript 2015
PPTX
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
PDF
ESCMAScript 6: Get Ready For The Future. Now
PDF
ES6, WTF?
PDF
JavaScript Core
PDF
The Future of JavaScript (Ajax Exp '07)
PDF
ES6 General Introduction
PPTX
ES6 - JavaCro 2016
PDF
JavaScript Primer
KEY
Exciting JavaScript - Part I
ES6: The future is now
JavaScript in 2016
JavaScript in 2016 (Codemotion Rome)
Awesomeness of JavaScript…almost
Workshop 10: ECMAScript 6
Academy PRO: ES2015
ECMAScript 6
JavaScript Growing Up
Fitc whats new in es6 for web devs
ECMAScript 2015
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
ESCMAScript 6: Get Ready For The Future. Now
ES6, WTF?
JavaScript Core
The Future of JavaScript (Ajax Exp '07)
ES6 General Introduction
ES6 - JavaCro 2016
JavaScript Primer
Exciting JavaScript - Part I

More from Sebastiano Armeli (10)

PDF
Managing a software engineering team
PDF
Enforcing coding standards in a JS project
PDF
Enforcing coding standards
PDF
Dependency management & Package management in JavaScript
PDF
Karma - JS Test Runner
PDF
KEY
Lazy load Everything!
KEY
MVC on the server and on the client
KEY
Getting started with Selenium 2
PDF
Web Storage
Managing a software engineering team
Enforcing coding standards in a JS project
Enforcing coding standards
Dependency management & Package management in JavaScript
Karma - JS Test Runner
Lazy load Everything!
MVC on the server and on the client
Getting started with Selenium 2
Web Storage

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

EcmaScript 6 - The future is here