SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
ECMAScript 6 Harmony
Major Changes
• class, module
• ‘const’,‘let’, destructuring
• for of
• Iterator and generator
• Default parameter
• Rest parameter and spread
• Arrow function
• Map, Set,WeakMap
• Array comprehension
• Proxy
• String extra, quasi-string literal
• Binary, octet, unicode literal
class, module
• class, extends
• constructor
• super
• module
• import, export
import $ from “jQuery”;
module “point” {
export class PointT extends Time {
constructor(x, y, t) {
super(t);
public getX() { return x; }
public getY() { return y; }
}
toString() {
return '<' + this.getX() + ',' + this.getY() + '>';
}
}
}
import PointT from “point”;
‘const’,‘let’, destructuring
• const
• let
• [x, y] = [y, x]
function Point5(x, y) {
const offset = 5;
if (x < offset) {
let y = 1;
x += y;
}
[x, y] = [ x+offset, y + offset];
return {x: x, y: y};
}
for of
• for (n of [ 1, 2, 3, 4, 5]) function Point6(x, y) {
var r = [1, 2, 3, 4, 5, 6, 7, 8, 9];
for (n of r) {
y = x + n;
}
return y;
}
Iterator and generator
• Iterator()
• #.next()
• yield
function Range(low, high) {
this.low = low;
this.high = high;
}
function RangeIterator(range) {
this.range = range;
this.current = this.range.low;
}
RangeIterator.prototype.next = function() {
if (this.current > this.range.high)
throw StopIteration;
else
return this.current++;
};
Range.prototype.__iterator__ = function() {
return new RangeIterator(this);
};
var range = new Range(3, 5);
for (var i in range) console.log(i);
function Range(low, high){
this.low = low;
this.high = high;
}
Range.prototype.__iterator__ = function(){
for (var i = this.low; i <= this.high; i++)
yield i;
};
Default parameter
• function (x=2) { } function Point7(x = 0, y = 0) {
return { x: x, y: y };
}
var p = Point7();
Rest parameter and spread
• function (...z) { }
• [1, 2, 3, ...[5, 6, 7]]
• f(...[2, 4, 6])
function f(w, x, y, z) {
return w * 1000 + x * 100 + y * 10 + z;
}
function g(...v) {
var w = v.length > 0 ? v[0] : 0;
var x = v.length > 1 ? v[1] : 0;
var y = v.length > 2 ? v[2] : 0;
var z = v.length > 3 ? v[3] : 0;
return w * 1000 + x * 100 + y * 10 + z;
}
var p = [2, 4, 6];
var q = [5, 7, ...p];
console.log(f(2,4,6,0));
console.log(g(2,4,6));
console.log(g(...q));
Arrow function
• function (a, b) { return a * b; }
• (a, b) => { a * b; }
• (a, b) => a * b;
• x => x * 3;
• () => {};
let empty = () => {};
 
let identity = x => x;
 
let square = x => x * x;
 
let key_maker = val => ({key: val});
 
let odds = evens.map(v => v + 1);
 
let fives = [];
nats.forEach(v => { if (v % 5 === 0) fives.push(v); });
 
const obj = {
method: function () {
return () => this;
}
};
assert(obj.method()() === obj);
Map, Set,WeakMap
• new Map()
• new Set()
• new WeakMap()
var m = new Map();
var s = new Set();
var w = new WeakMap();
var ko = {}, kf = function(){};
m.set(ko “object”);
m.set(kf,“function”);
m.set(“a”,“string”);
m.size == 3;
m.get(“a”);
m.get(ko);
m.get(kf);
s.set(5);
s.set(“string”);
s.size == 2;
s.has(5);
for (var n of s) console.log(n);
Array comprehension
• [n for (n of [5, 6, 7])] var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var b = [n*2 for (n of a)];
var c = [n for (n of a) if (n % 2)];
var d = [i+j for (i of a) for (j of a)];
Proxy
• new Proxy({}, {}) 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
String extra, quasi-string literal
• startsWith
• endsWith
• contains
• toArray
• f`hello ${name}`
var s = “String extra, quasi-string literal”;
s.startsWith(“String”) == true;
s.endsWith(“literal”) == true;
s.contains(“quasi”) == true;
s.toArray();
function f(s) {
console.log(s);
return s;
}
var name = “everyone”;
f`hello ${name}.`;
Binary, octet, unicode literal
• 0b010101
• 0o77
• 'u{1d306}' == 'ud834udf06'

Mais conteúdo relacionado

Mais procurados

OpenOpt の線形計画で圧縮センシング
OpenOpt の線形計画で圧縮センシングOpenOpt の線形計画で圧縮センシング
OpenOpt の線形計画で圧縮センシングToshihiro Kamishima
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmKapil Pandit
 
Superficies en maple
Superficies en mapleSuperficies en maple
Superficies en mapleaart07
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicalsManoj Chauhan
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonChristoph Matthies
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacionJeff Tu Pechito
 
Deep learning study 3
Deep learning study 3Deep learning study 3
Deep learning study 3San Kim
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180Mahmoud Samir Fayed
 

Mais procurados (20)

OpenOpt の線形計画で圧縮センシング
OpenOpt の線形計画で圧縮センシングOpenOpt の線形計画で圧縮センシング
OpenOpt の線形計画で圧縮センシング
 
Vcs9
Vcs9Vcs9
Vcs9
 
C questions
C questionsC questions
C questions
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
Superficies en maple
Superficies en mapleSuperficies en maple
Superficies en maple
 
R meets Hadoop
R meets HadoopR meets Hadoop
R meets Hadoop
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in Python
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
JVM Architecture - Java
JVM Architecture - JavaJVM Architecture - Java
JVM Architecture - Java
 
RHadoop の紹介
RHadoop の紹介RHadoop の紹介
RHadoop の紹介
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Deep learning study 3
Deep learning study 3Deep learning study 3
Deep learning study 3
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
 
Caropro
CaroproCaropro
Caropro
 
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
 

Destaque

Let's get agile: An Agile Talk About Agile
Let's get agile: An Agile Talk About AgileLet's get agile: An Agile Talk About Agile
Let's get agile: An Agile Talk About AgileJesse Houwing
 
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...Kevin Shea
 
Expande tu Negocio con Email Marketing
Expande tu Negocio con Email MarketingExpande tu Negocio con Email Marketing
Expande tu Negocio con Email MarketingArmando Ehrenzweig
 
Lg15fall cara à cara30octf
Lg15fall cara à cara30octfLg15fall cara à cara30octf
Lg15fall cara à cara30octfkatherine watson
 
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja Escuela
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja EscuelaCampamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja Escuela
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja EscuelaVeleta3000
 
Presentacion pp calafate y glaciar perito moreno
Presentacion pp calafate y glaciar perito morenoPresentacion pp calafate y glaciar perito moreno
Presentacion pp calafate y glaciar perito morenosilviaoswald
 
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...Anibal Leon Fernandez
 
Government Publications August 2015 Library Guide (4)
Government Publications August 2015 Library Guide (4)Government Publications August 2015 Library Guide (4)
Government Publications August 2015 Library Guide (4)Mary Howrey
 
Povertyy education
Povertyy educationPovertyy education
Povertyy educationTARIQ KHAN
 
European flags
European flagsEuropean flags
European flagsivid1990
 
Boletim Dom Edilberto - outubro/2013 - nº 56
Boletim Dom Edilberto - outubro/2013 - nº 56Boletim Dom Edilberto - outubro/2013 - nº 56
Boletim Dom Edilberto - outubro/2013 - nº 56escoladomedilberto
 
Glosario ecologia y calentmiento
Glosario ecologia y calentmientoGlosario ecologia y calentmiento
Glosario ecologia y calentmientoDeuglissabino
 
Ansiedad y angustia
Ansiedad y angustiaAnsiedad y angustia
Ansiedad y angustiaeduarfrasa
 
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorr
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-DorrFlipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorr
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorrmhhighered
 
Conceptos
ConceptosConceptos
Conceptosnay_isa
 
Actividad de aprendisaje nª 8
Actividad de aprendisaje nª 8Actividad de aprendisaje nª 8
Actividad de aprendisaje nª 8migelx
 
El futuro de_la_comunicacion_1_
El futuro de_la_comunicacion_1_El futuro de_la_comunicacion_1_
El futuro de_la_comunicacion_1_leslyevqz
 

Destaque (20)

Let's get agile: An Agile Talk About Agile
Let's get agile: An Agile Talk About AgileLet's get agile: An Agile Talk About Agile
Let's get agile: An Agile Talk About Agile
 
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...
Case Study: Enhancing Sponsor Value through the Extension of Vendor-provided ...
 
Expande tu Negocio con Email Marketing
Expande tu Negocio con Email MarketingExpande tu Negocio con Email Marketing
Expande tu Negocio con Email Marketing
 
Lg15fall cara à cara30octf
Lg15fall cara à cara30octfLg15fall cara à cara30octf
Lg15fall cara à cara30octf
 
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja Escuela
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja EscuelaCampamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja Escuela
Campamentos de Verano Sierra de Cadiz Aula Naturaleza y Granja Escuela
 
Presentacion pp calafate y glaciar perito moreno
Presentacion pp calafate y glaciar perito morenoPresentacion pp calafate y glaciar perito moreno
Presentacion pp calafate y glaciar perito moreno
 
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...
Relaciones Públicas. 2.0: El uso de los medios sociales en la estrategia de c...
 
Government Publications August 2015 Library Guide (4)
Government Publications August 2015 Library Guide (4)Government Publications August 2015 Library Guide (4)
Government Publications August 2015 Library Guide (4)
 
Povertyy education
Povertyy educationPovertyy education
Povertyy education
 
European flags
European flagsEuropean flags
European flags
 
Boletim Dom Edilberto - outubro/2013 - nº 56
Boletim Dom Edilberto - outubro/2013 - nº 56Boletim Dom Edilberto - outubro/2013 - nº 56
Boletim Dom Edilberto - outubro/2013 - nº 56
 
Glosario ecologia y calentmiento
Glosario ecologia y calentmientoGlosario ecologia y calentmiento
Glosario ecologia y calentmiento
 
Ansiedad y angustia
Ansiedad y angustiaAnsiedad y angustia
Ansiedad y angustia
 
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorr
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-DorrFlipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorr
Flipping the Classroom with McGraw-Hill Connect - Dana'e Quirk-Dorr
 
Conceptos
ConceptosConceptos
Conceptos
 
Tarea 8
Tarea 8Tarea 8
Tarea 8
 
Actividad de aprendisaje nª 8
Actividad de aprendisaje nª 8Actividad de aprendisaje nª 8
Actividad de aprendisaje nª 8
 
Fluoxetine 2002
Fluoxetine 2002Fluoxetine 2002
Fluoxetine 2002
 
Damai residences and lifestyle
Damai residences and lifestyleDamai residences and lifestyle
Damai residences and lifestyle
 
El futuro de_la_comunicacion_1_
El futuro de_la_comunicacion_1_El futuro de_la_comunicacion_1_
El futuro de_la_comunicacion_1_
 

Semelhante a ECMAScript 6 major changes

Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
ES6 and AngularAMD
ES6 and AngularAMDES6 and AngularAMD
ES6 and AngularAMDdhaval10690
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programmingjeffz
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfKARTIKINDIA
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Paperjs presentation
Paperjs presentationPaperjs presentation
Paperjs presentationsharp-blade
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programmingLukasz Dynowski
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)hhliu
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscexjeffz
 
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽tbosstraining
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 

Semelhante a ECMAScript 6 major changes (20)

Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
ES6 and AngularAMD
ES6 and AngularAMDES6 and AngularAMD
ES6 and AngularAMD
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdf
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Paperjs presentation
Paperjs presentationPaperjs presentation
Paperjs presentation
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Javascript
JavascriptJavascript
Javascript
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

ECMAScript 6 major changes

  • 2. Major Changes • class, module • ‘const’,‘let’, destructuring • for of • Iterator and generator • Default parameter • Rest parameter and spread • Arrow function • Map, Set,WeakMap • Array comprehension • Proxy • String extra, quasi-string literal • Binary, octet, unicode literal
  • 3. class, module • class, extends • constructor • super • module • import, export import $ from “jQuery”; module “point” { export class PointT extends Time { constructor(x, y, t) { super(t); public getX() { return x; } public getY() { return y; } } toString() { return '<' + this.getX() + ',' + this.getY() + '>'; } } } import PointT from “point”;
  • 4. ‘const’,‘let’, destructuring • const • let • [x, y] = [y, x] function Point5(x, y) { const offset = 5; if (x < offset) { let y = 1; x += y; } [x, y] = [ x+offset, y + offset]; return {x: x, y: y}; }
  • 5. for of • for (n of [ 1, 2, 3, 4, 5]) function Point6(x, y) { var r = [1, 2, 3, 4, 5, 6, 7, 8, 9]; for (n of r) { y = x + n; } return y; }
  • 6. Iterator and generator • Iterator() • #.next() • yield function Range(low, high) { this.low = low; this.high = high; } function RangeIterator(range) { this.range = range; this.current = this.range.low; } RangeIterator.prototype.next = function() { if (this.current > this.range.high) throw StopIteration; else return this.current++; }; Range.prototype.__iterator__ = function() { return new RangeIterator(this); }; var range = new Range(3, 5); for (var i in range) console.log(i); function Range(low, high){ this.low = low; this.high = high; } Range.prototype.__iterator__ = function(){ for (var i = this.low; i <= this.high; i++) yield i; };
  • 7. Default parameter • function (x=2) { } function Point7(x = 0, y = 0) { return { x: x, y: y }; } var p = Point7();
  • 8. Rest parameter and spread • function (...z) { } • [1, 2, 3, ...[5, 6, 7]] • f(...[2, 4, 6]) function f(w, x, y, z) { return w * 1000 + x * 100 + y * 10 + z; } function g(...v) { var w = v.length > 0 ? v[0] : 0; var x = v.length > 1 ? v[1] : 0; var y = v.length > 2 ? v[2] : 0; var z = v.length > 3 ? v[3] : 0; return w * 1000 + x * 100 + y * 10 + z; } var p = [2, 4, 6]; var q = [5, 7, ...p]; console.log(f(2,4,6,0)); console.log(g(2,4,6)); console.log(g(...q));
  • 9. Arrow function • function (a, b) { return a * b; } • (a, b) => { a * b; } • (a, b) => a * b; • x => x * 3; • () => {}; let empty = () => {};   let identity = x => x;   let square = x => x * x;   let key_maker = val => ({key: val});   let odds = evens.map(v => v + 1);   let fives = []; nats.forEach(v => { if (v % 5 === 0) fives.push(v); });   const obj = { method: function () { return () => this; } }; assert(obj.method()() === obj);
  • 10. Map, Set,WeakMap • new Map() • new Set() • new WeakMap() var m = new Map(); var s = new Set(); var w = new WeakMap(); var ko = {}, kf = function(){}; m.set(ko “object”); m.set(kf,“function”); m.set(“a”,“string”); m.size == 3; m.get(“a”); m.get(ko); m.get(kf); s.set(5); s.set(“string”); s.size == 2; s.has(5); for (var n of s) console.log(n);
  • 11. Array comprehension • [n for (n of [5, 6, 7])] var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var b = [n*2 for (n of a)]; var c = [n for (n of a) if (n % 2)]; var d = [i+j for (i of a) for (j of a)];
  • 12. Proxy • new Proxy({}, {}) 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
  • 13. String extra, quasi-string literal • startsWith • endsWith • contains • toArray • f`hello ${name}` var s = “String extra, quasi-string literal”; s.startsWith(“String”) == true; s.endsWith(“literal”) == true; s.contains(“quasi”) == true; s.toArray(); function f(s) { console.log(s); return s; } var name = “everyone”; f`hello ${name}.`;
  • 14. Binary, octet, unicode literal • 0b010101 • 0o77 • 'u{1d306}' == 'ud834udf06'