SlideShare a Scribd company logo
<web/F>	
  <web/F>	
  
ECMAScript  6
An	
  Overview	
  
<web/F>	
  <web/F>	
  
What  we  need  ?

•  Code	
  organiza0on	
  
•  Readability	
  	
  
•  Syntax	
  Improvement	
  for	
  basic	
  opera0ons	
  
•  More	
  Control	
  
•  Be@er	
  support	
  for	
  Unicode	
  
•  Get	
  rid	
  of	
  workarounds	
  
•  Predictability	
  
	
  
	
  
	
  
<web/F>	
  <web/F>	
  
Func8on  Parameters  -­‐-­‐  Default  Values
//ECMA5
function multiply(a, b ) {
b = typeof b == 'number' ? b : 1;
return a*b;
}
//ECMA6
function multiply(a, b = 1) {
return a*b;
}
	
  
<web/F>	
  <web/F>	
  
Func8on  Parameters  -­‐-­‐  Computa8on
function singularAutoPlural(
singular,
plural = singular+"s",
rallyingCry = plural + " ATTACK!!!") {
return [singular, plural, rallyingCry ];
}
	
  
<web/F>	
  <web/F>	
  
Func8on  Parameters  -­‐-­‐  Rest  Params
function add(a,...all){
var sum=a;
all.forEach(function(value){
sum+=value;
})
return sum;
}	
  
<web/F>	
  <web/F>	
  
Spread  Operator
var arr1 = [0, 1, 2];
var arr2 = [3, 4, 5];
//ECMA 5 way
Array.prototype.push.apply(arr1, arr2);
//ECMA 6 way
arr1.push(...arr2);//arr1.push(3,4,5)
function add(a,b){ return a+b; }
add(...arr2);//7
<web/F>	
  <web/F>	
  
Object  Literal  -­‐  Short  hand
var first=”A”,
last=”Z”;
//ECMA5 way
var obj = { first: first,
last: last,
foo:function(){} };
//ECMA6
var obj = { first,
last,
foo(){} };
<web/F>	
  <web/F>	
  
Object  Literal  -­‐  Computed,  GeIer,  SeIer
//ECMA5
var obj={};
obj['a'+0]='value';
//ECMA6
var obj={
['a'+0]:'value',
get name(){ return 'hello';}
}
<web/F>	
  <web/F>	
  
for-­‐of  
//iterate values
let arr = ['foo', 'bar', 'baz'];
for (let element of arr) {
console.log(element);//for,bar,baz
}
<web/F>	
  <web/F>	
  
Octal  and  Binary  Literals
0o10 == 8
0O10 == 8
0b10 == 2
0B10 == 2
Number('0b01')==1
<web/F>	
  <web/F>	
  
String  Templates
var name = 'Jane';
var str = `Hi ${name}! 3
plus 4 is ${3+4}`;
console.log(str);//Hi Jane 3 plus 4 is 7
//tagged template for customization
<web/F>	
  <web/F>	
  
Destructuring
var [a,b]=["value1","value2"];
var [a,,b]=[0,1,2];
var [a,b,...c]=[0,1,2,3,4];
var {first,last}={first:"A",last:"Z"};
var {first:f,last:target}
={first:"A",last:"Z"};
Console.log(f);//A
<web/F>	
  <web/F>	
  
Block  Func8ons
function foo(){
'use strict';
function fun(){return 'outer';}
if(true){
function fun(){return 'inner';}
fun();//inner
}
fun();//outer
}
<web/F>	
  <web/F>	
  
Block  Variables
let a=20;
for(let i=0;i<10;i++){
let value=i;
setTimeout(function(){
console.log(value);
},1);
}
<web/F>	
  <web/F>	
  
Constants
const bar = 123;
bar = 45; // error in strict mode
{ const bar = 456; }
bar === 123;
<web/F>	
  <web/F>	
  
Arrow  Func8ons
//ECMA5
var arr = [1, 2, 3];
var squares = arr.map(function(x){ return
x*x; });
//ECMA6
let arr = [1, 2, 3];
let squares = arr.map(x => x * x);
<web/F>	
  <web/F>	
  
Arrow  Func8ons  -­‐  this
// `this` is picked up from surroundings (lexical)
// Therefore: no more `that = this` or bind()
function UiComponent {
let button =
document.getElementById('myButton');
button.addEventListener('click', () => {
console.log('CLICK');
this.handleClick(); // lexical `this`
});
}
<web/F>	
  <web/F>	
  
Arrow  Func8ons  -­‐  Usage
no argument
() => Math.random();
one argument
x => x*x;
multiple arguments
(x,y) => x*y;
rest parameters
(x,y,..all) => x*y*all.length;
returning object
(x) =>({value:x})
Multiple statements
(x,y) => { doSomething(x,y); return x*y;}
<web/F>	
  <web/F>	
  
Class
Extension
Super reference
constructor
static methods, properties
<web/F>	
  <web/F>	
  
Class
class Person {
constructor(name) { this.name = name; },
describe() { return 'Person called ' + this.name; }
}
class Employee extends Person {
static employer(){ return “Globant”; },
constructor(name, title) {
super(name);
this.title = title;
},
describe() {return super.describe() + '(' + this.title + ')'; }
}
<web/F>	
  <web/F>	
  
Generators
function* idMaker(){
var index = 0;
while(index < 3)
yield index++;
}
for(var k of idMaker()){ console.log(k) }//0,1,2
var gen = idMaker();
console.log(gen.next().value); // 0
console.log(gen.next().value); // 1
console.log(gen.next().value); // 2
console.log(gen.next().value); // undefined
<web/F>	
  <web/F>	
  
Generators  -­‐  Delega8on
function* g1() {
yield 2;
}
function* g2() {
yield 1;
yield* g1();
}
var iterator = g2();
console.log(iterator.next()); // { value: 1, done: false }
console.log(iterator.next()); // { value: 2, done: false }
console.log(iterator.next()); // { value: undefined, done: true }
<web/F>	
  <web/F>	
  
Proxies  -­‐  Set
let validator = {
set: function(obj, prop, value) {
if (prop === 'age') {
if (!Number.isInteger(value)){throw new TypeError('The age is not an
integer');}
if (value > 200) {throw new RangeError('The age seems invalid');}
}
obj[prop] = value;
}
};
let person = new Proxy({}, validator);
person.age = 100;
console.log(person.age); // 100
person.age = 'young'; // Throws an exception
<web/F>	
  <web/F>	
  
Proxies  -­‐  Get
var handler = {
get: function(target, name){
return name in target?
target[name] : 37;
}
};
var p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;
console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
<web/F>	
  <web/F>	
  
Modules  
//------ lib.js ------
export const sqrt = Math.sqrt;
export function square(x) {
return x * x;
}
//------ main.js ------
import { square, diag } from 'lib';
console.log(square(11)); // 121
//System.import
<web/F>	
  <web/F>	
  
Symbols  
//new kind of primitive value
//each symbol is unique
Symbol()==Symbol();//false
Symbol.for("sym")//Symbol(sym)
Symbol("sym")==Symbol.for("sym");//false
<web/F>	
  <web/F>	
  
Symbols  
var myIterable = {};
myIterable[Symbol.iterator] = function* () {
yield 1;
yield 2;
yield 3;
};
[...myIterable] // [1, 2, 3]
<web/F>	
  <web/F>	
  
Map  and  Set  
var m = new Map(),s={};
m.set("hello", 42);
m.set(s, 34);
m.get(s) == 34;
//object, size , order in enumeration
var s = new Set();
s.add("hello").add("goodbye").add("hello");
s.size === 2;
s.has("hello") === true;
<web/F>	
  <web/F>	
  
WeakMap  and  WeakSet  
var wm = new WeakMap(),s={};
wm.set(s, { extra: 42 });
wm.size === undefined
WeakSet: add,delete,has only
//Only Objects
//garbage collection
//no size property
//no enumeration
<web/F>	
  <web/F>	
  
More..
Unicode support
Subclassing a builtins
Promises
Reflect
Tail Call Optimization,
New API’s - Math,Number,String,Array,Object
<web/F>	
  <web/F>	
  
Current  Support
h@ps://kangax.github.io/compat-­‐table/es6/	
  
Browsers	
  
•  Firefox-­‐39:66%	
  ,	
  FF41:69%	
  
•  MicrosoS	
  Edge	
  :	
  66%	
  
•  Chrome:56%	
  
	
  
Compiler	
  
Babel	
  :	
  71%	
  
Traceur:59%	
  
	
  
	
  
<web/F>	
  <web/F>	
  
What  we  need  ?

•  Code	
  organiza0on	
  –	
  Classes,modules	
  
•  Readability	
  –	
  destructuring,	
  arrow	
  func0ons,	
  classes,	
  extend,	
  super	
  
•  Syntax	
  Improvement	
  for	
  basic	
  opera0ons	
  –	
  rest,	
  spread,	
  	
  destructuring	
  
•  More	
  Control	
  –	
  Proxies,	
  super,	
  symbol	
  
•  Be@er	
  support	
  for	
  Unicode	
  -­‐-­‐	
  	
  regex	
  flags,	
  string	
  length	
  
•  Get	
  rid	
  of	
  workarounds	
  –	
  Default	
  Parameter	
  Value,	
  let	
  ,	
  const	
  
•  Predictability	
  –	
  Scope	
  Func0ons,	
  let,	
  const	
  
•  Performance	
  –	
  Generators,	
  Tail	
  Call	
  Op0miza0on	
  
	
  
	
  
	
  

More Related Content

What's hot

Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)
James Titcumb
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
James Titcumb
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
Ramesh Nair
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
dantleech
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
Vic Metcalfe
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
Dharmalingam Ganesan
 
Php 5.6
Php 5.6Php 5.6
Perl one liners
Perl one linersPerl one liners
Perl one liners
Shaun Griffith
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
Programmer Blog
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
FITC
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
alexgolec
 
ScalaFlavor4J
ScalaFlavor4JScalaFlavor4J
ScalaFlavor4J
Kazuhiro Sera
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
Lin Yo-An
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.
lnikolaeva
 

What's hot (20)

Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Php 5.6
Php 5.6Php 5.6
Php 5.6
 
C++ programs
C++ programsC++ programs
C++ programs
 
Gun make
Gun makeGun make
Gun make
 
Perl one liners
Perl one linersPerl one liners
Perl one liners
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
 
ScalaFlavor4J
ScalaFlavor4JScalaFlavor4J
ScalaFlavor4J
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.
 

Viewers also liked

Vagrant Workshop
Vagrant WorkshopVagrant Workshop
Vagrant Workshop
sys army
 
Baclofene Posologie
Baclofene PosologieBaclofene Posologie
Baclofene Posologie
logicelemaling
 
Elmhurst tech net cardiff 241115
Elmhurst tech net cardiff 241115Elmhurst tech net cardiff 241115
Elmhurst tech net cardiff 241115
Nicola Scott
 
Al Bustan Art Boutique Feb 4 2016
Al Bustan Art Boutique Feb 4 2016Al Bustan Art Boutique Feb 4 2016
Al Bustan Art Boutique Feb 4 2016Liju Cherian
 
Baclofene Posologie
Baclofene PosologieBaclofene Posologie
Baclofene Posologie
logicelemaling
 
Aligning People, Processes and Technology in Field Service
Aligning People, Processes and Technology in Field ServiceAligning People, Processes and Technology in Field Service
Aligning People, Processes and Technology in Field Service
fieldaware1
 
Group (1)
Group (1)Group (1)
Group (1)
howcyong1011
 
Global company, global brand
Global company, global brandGlobal company, global brand
Global company, global brand
John Oscar Mueda
 
Ggogogogoog
GgogogogoogGgogogogoog
Ggogogogoog
karenastronomia
 
Ticari Mutfaklar için Enerji Verimliliği Çözümleri
Ticari Mutfaklar için Enerji Verimliliği ÇözümleriTicari Mutfaklar için Enerji Verimliliği Çözümleri
Ticari Mutfaklar için Enerji Verimliliği ÇözümleriHVAC Dünyası
 
Top 8 class a driver resume samples
Top 8 class a driver resume samplesTop 8 class a driver resume samples
Top 8 class a driver resume samplesRihannaEminem678
 
Top 8 commercial leasing agent resume samples
Top 8 commercial leasing agent resume samplesTop 8 commercial leasing agent resume samples
Top 8 commercial leasing agent resume samplesRihannaEminem678
 
Rubber fenders
Rubber  fendersRubber  fenders
Rubber fenders
Stella Cheng
 
Getting at the goals of the customer
Getting at the goals of the customerGetting at the goals of the customer
Getting at the goals of the customer
Voluntas_Insights
 

Viewers also liked (14)

Vagrant Workshop
Vagrant WorkshopVagrant Workshop
Vagrant Workshop
 
Baclofene Posologie
Baclofene PosologieBaclofene Posologie
Baclofene Posologie
 
Elmhurst tech net cardiff 241115
Elmhurst tech net cardiff 241115Elmhurst tech net cardiff 241115
Elmhurst tech net cardiff 241115
 
Al Bustan Art Boutique Feb 4 2016
Al Bustan Art Boutique Feb 4 2016Al Bustan Art Boutique Feb 4 2016
Al Bustan Art Boutique Feb 4 2016
 
Baclofene Posologie
Baclofene PosologieBaclofene Posologie
Baclofene Posologie
 
Aligning People, Processes and Technology in Field Service
Aligning People, Processes and Technology in Field ServiceAligning People, Processes and Technology in Field Service
Aligning People, Processes and Technology in Field Service
 
Group (1)
Group (1)Group (1)
Group (1)
 
Global company, global brand
Global company, global brandGlobal company, global brand
Global company, global brand
 
Ggogogogoog
GgogogogoogGgogogogoog
Ggogogogoog
 
Ticari Mutfaklar için Enerji Verimliliği Çözümleri
Ticari Mutfaklar için Enerji Verimliliği ÇözümleriTicari Mutfaklar için Enerji Verimliliği Çözümleri
Ticari Mutfaklar için Enerji Verimliliği Çözümleri
 
Top 8 class a driver resume samples
Top 8 class a driver resume samplesTop 8 class a driver resume samples
Top 8 class a driver resume samples
 
Top 8 commercial leasing agent resume samples
Top 8 commercial leasing agent resume samplesTop 8 commercial leasing agent resume samples
Top 8 commercial leasing agent resume samples
 
Rubber fenders
Rubber  fendersRubber  fenders
Rubber fenders
 
Getting at the goals of the customer
Getting at the goals of the customerGetting at the goals of the customer
Getting at the goals of the customer
 

Similar to ECMAScript 6

Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
Visual Engineering
 
Javascript
JavascriptJavascript
Javascript
Vlad Ifrim
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
Sperasoft
 
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 6Dmitry Soshnikov
 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
Binary Studio
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
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
Krzysztof Szafranek
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
Luis Vendrame
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
Movel
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
Bruno Scopelliti
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
stefanmayer13
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
Michael Girouard
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
Manoj Kumar
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
Anjan Banda
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
Harleen Sodhi
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
Domenic Denicola
 

Similar to ECMAScript 6 (20)

Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Javascript
JavascriptJavascript
Javascript
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
 
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
 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
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
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 

More from WebF

IV - CSS architecture
IV - CSS architectureIV - CSS architecture
IV - CSS architecture
WebF
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjs
WebF
 
II - Angular.js app structure
II - Angular.js app structureII - Angular.js app structure
II - Angular.js app structure
WebF
 
2015 - Introduction to building enterprise web applications using Angular.js
2015 - Introduction to building enterprise web applications using Angular.js2015 - Introduction to building enterprise web applications using Angular.js
2015 - Introduction to building enterprise web applications using Angular.js
WebF
 
II - Build Automation
II - Build AutomationII - Build Automation
II - Build Automation
WebF
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
WebF
 
Asynchronous Programming with JavaScript
Asynchronous Programming with JavaScriptAsynchronous Programming with JavaScript
Asynchronous Programming with JavaScript
WebF
 
Keynote - WebF 2015
Keynote - WebF 2015Keynote - WebF 2015
Keynote - WebF 2015
WebF
 
I - Front-end Spectrum
I - Front-end SpectrumI - Front-end Spectrum
I - Front-end Spectrum
WebF
 

More from WebF (9)

IV - CSS architecture
IV - CSS architectureIV - CSS architecture
IV - CSS architecture
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjs
 
II - Angular.js app structure
II - Angular.js app structureII - Angular.js app structure
II - Angular.js app structure
 
2015 - Introduction to building enterprise web applications using Angular.js
2015 - Introduction to building enterprise web applications using Angular.js2015 - Introduction to building enterprise web applications using Angular.js
2015 - Introduction to building enterprise web applications using Angular.js
 
II - Build Automation
II - Build AutomationII - Build Automation
II - Build Automation
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
Asynchronous Programming with JavaScript
Asynchronous Programming with JavaScriptAsynchronous Programming with JavaScript
Asynchronous Programming with JavaScript
 
Keynote - WebF 2015
Keynote - WebF 2015Keynote - WebF 2015
Keynote - WebF 2015
 
I - Front-end Spectrum
I - Front-end SpectrumI - Front-end Spectrum
I - Front-end Spectrum
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

ECMAScript 6

  • 1. <web/F>  <web/F>   ECMAScript  6 An  Overview  
  • 2. <web/F>  <web/F>   What  we  need  ? •  Code  organiza0on   •  Readability     •  Syntax  Improvement  for  basic  opera0ons   •  More  Control   •  Be@er  support  for  Unicode   •  Get  rid  of  workarounds   •  Predictability        
  • 3. <web/F>  <web/F>   Func8on  Parameters  -­‐-­‐  Default  Values //ECMA5 function multiply(a, b ) { b = typeof b == 'number' ? b : 1; return a*b; } //ECMA6 function multiply(a, b = 1) { return a*b; }  
  • 4. <web/F>  <web/F>   Func8on  Parameters  -­‐-­‐  Computa8on function singularAutoPlural( singular, plural = singular+"s", rallyingCry = plural + " ATTACK!!!") { return [singular, plural, rallyingCry ]; }  
  • 5. <web/F>  <web/F>   Func8on  Parameters  -­‐-­‐  Rest  Params function add(a,...all){ var sum=a; all.forEach(function(value){ sum+=value; }) return sum; }  
  • 6. <web/F>  <web/F>   Spread  Operator var arr1 = [0, 1, 2]; var arr2 = [3, 4, 5]; //ECMA 5 way Array.prototype.push.apply(arr1, arr2); //ECMA 6 way arr1.push(...arr2);//arr1.push(3,4,5) function add(a,b){ return a+b; } add(...arr2);//7
  • 7. <web/F>  <web/F>   Object  Literal  -­‐  Short  hand var first=”A”, last=”Z”; //ECMA5 way var obj = { first: first, last: last, foo:function(){} }; //ECMA6 var obj = { first, last, foo(){} };
  • 8. <web/F>  <web/F>   Object  Literal  -­‐  Computed,  GeIer,  SeIer //ECMA5 var obj={}; obj['a'+0]='value'; //ECMA6 var obj={ ['a'+0]:'value', get name(){ return 'hello';} }
  • 9. <web/F>  <web/F>   for-­‐of   //iterate values let arr = ['foo', 'bar', 'baz']; for (let element of arr) { console.log(element);//for,bar,baz }
  • 10. <web/F>  <web/F>   Octal  and  Binary  Literals 0o10 == 8 0O10 == 8 0b10 == 2 0B10 == 2 Number('0b01')==1
  • 11. <web/F>  <web/F>   String  Templates var name = 'Jane'; var str = `Hi ${name}! 3 plus 4 is ${3+4}`; console.log(str);//Hi Jane 3 plus 4 is 7 //tagged template for customization
  • 12. <web/F>  <web/F>   Destructuring var [a,b]=["value1","value2"]; var [a,,b]=[0,1,2]; var [a,b,...c]=[0,1,2,3,4]; var {first,last}={first:"A",last:"Z"}; var {first:f,last:target} ={first:"A",last:"Z"}; Console.log(f);//A
  • 13. <web/F>  <web/F>   Block  Func8ons function foo(){ 'use strict'; function fun(){return 'outer';} if(true){ function fun(){return 'inner';} fun();//inner } fun();//outer }
  • 14. <web/F>  <web/F>   Block  Variables let a=20; for(let i=0;i<10;i++){ let value=i; setTimeout(function(){ console.log(value); },1); }
  • 15. <web/F>  <web/F>   Constants const bar = 123; bar = 45; // error in strict mode { const bar = 456; } bar === 123;
  • 16. <web/F>  <web/F>   Arrow  Func8ons //ECMA5 var arr = [1, 2, 3]; var squares = arr.map(function(x){ return x*x; }); //ECMA6 let arr = [1, 2, 3]; let squares = arr.map(x => x * x);
  • 17. <web/F>  <web/F>   Arrow  Func8ons  -­‐  this // `this` is picked up from surroundings (lexical) // Therefore: no more `that = this` or bind() function UiComponent { let button = document.getElementById('myButton'); button.addEventListener('click', () => { console.log('CLICK'); this.handleClick(); // lexical `this` }); }
  • 18. <web/F>  <web/F>   Arrow  Func8ons  -­‐  Usage no argument () => Math.random(); one argument x => x*x; multiple arguments (x,y) => x*y; rest parameters (x,y,..all) => x*y*all.length; returning object (x) =>({value:x}) Multiple statements (x,y) => { doSomething(x,y); return x*y;}
  • 19. <web/F>  <web/F>   Class Extension Super reference constructor static methods, properties
  • 20. <web/F>  <web/F>   Class class Person { constructor(name) { this.name = name; }, describe() { return 'Person called ' + this.name; } } class Employee extends Person { static employer(){ return “Globant”; }, constructor(name, title) { super(name); this.title = title; }, describe() {return super.describe() + '(' + this.title + ')'; } }
  • 21. <web/F>  <web/F>   Generators function* idMaker(){ var index = 0; while(index < 3) yield index++; } for(var k of idMaker()){ console.log(k) }//0,1,2 var gen = idMaker(); console.log(gen.next().value); // 0 console.log(gen.next().value); // 1 console.log(gen.next().value); // 2 console.log(gen.next().value); // undefined
  • 22. <web/F>  <web/F>   Generators  -­‐  Delega8on function* g1() { yield 2; } function* g2() { yield 1; yield* g1(); } var iterator = g2(); console.log(iterator.next()); // { value: 1, done: false } console.log(iterator.next()); // { value: 2, done: false } console.log(iterator.next()); // { value: undefined, done: true }
  • 23. <web/F>  <web/F>   Proxies  -­‐  Set let validator = { set: function(obj, prop, value) { if (prop === 'age') { if (!Number.isInteger(value)){throw new TypeError('The age is not an integer');} if (value > 200) {throw new RangeError('The age seems invalid');} } obj[prop] = value; } }; let person = new Proxy({}, validator); person.age = 100; console.log(person.age); // 100 person.age = 'young'; // Throws an exception
  • 24. <web/F>  <web/F>   Proxies  -­‐  Get var handler = { get: function(target, name){ return name in target? target[name] : 37; } }; var p = new Proxy({}, handler); p.a = 1; p.b = undefined; console.log(p.a, p.b); // 1, undefined console.log('c' in p, p.c); // false, 37
  • 25. <web/F>  <web/F>   Modules   //------ lib.js ------ export const sqrt = Math.sqrt; export function square(x) { return x * x; } //------ main.js ------ import { square, diag } from 'lib'; console.log(square(11)); // 121 //System.import
  • 26. <web/F>  <web/F>   Symbols   //new kind of primitive value //each symbol is unique Symbol()==Symbol();//false Symbol.for("sym")//Symbol(sym) Symbol("sym")==Symbol.for("sym");//false
  • 27. <web/F>  <web/F>   Symbols   var myIterable = {}; myIterable[Symbol.iterator] = function* () { yield 1; yield 2; yield 3; }; [...myIterable] // [1, 2, 3]
  • 28. <web/F>  <web/F>   Map  and  Set   var m = new Map(),s={}; m.set("hello", 42); m.set(s, 34); m.get(s) == 34; //object, size , order in enumeration var s = new Set(); s.add("hello").add("goodbye").add("hello"); s.size === 2; s.has("hello") === true;
  • 29. <web/F>  <web/F>   WeakMap  and  WeakSet   var wm = new WeakMap(),s={}; wm.set(s, { extra: 42 }); wm.size === undefined WeakSet: add,delete,has only //Only Objects //garbage collection //no size property //no enumeration
  • 30. <web/F>  <web/F>   More.. Unicode support Subclassing a builtins Promises Reflect Tail Call Optimization, New API’s - Math,Number,String,Array,Object
  • 31. <web/F>  <web/F>   Current  Support h@ps://kangax.github.io/compat-­‐table/es6/   Browsers   •  Firefox-­‐39:66%  ,  FF41:69%   •  MicrosoS  Edge  :  66%   •  Chrome:56%     Compiler   Babel  :  71%   Traceur:59%      
  • 32. <web/F>  <web/F>   What  we  need  ? •  Code  organiza0on  –  Classes,modules   •  Readability  –  destructuring,  arrow  func0ons,  classes,  extend,  super   •  Syntax  Improvement  for  basic  opera0ons  –  rest,  spread,    destructuring   •  More  Control  –  Proxies,  super,  symbol   •  Be@er  support  for  Unicode  -­‐-­‐    regex  flags,  string  length   •  Get  rid  of  workarounds  –  Default  Parameter  Value,  let  ,  const   •  Predictability  –  Scope  Func0ons,  let,  const   •  Performance  –  Generators,  Tail  Call  Op0miza0on