SlideShare a Scribd company logo
1 of 20
ECMAscript 6
ME
• Ofir Fridman
• FE Developer
• Love code, technology, sport
JavaScript History
• Beginnings at Netscape
• JavaScript was originally developed by Brendan Eich,
• The first version was completed in ten days
• JavaScript first called Mocha, which was later renamed
LiveScript in September 1995 and later JavaScript
The JavaScript Timeline
Browser Statistics
2015 Chrome IE Firefox Safari Opera
April 63.9 % 8.0 % 21.6 % 3.8 % 1.5 %
March 63.7 % 7.7 % 22.1 % 3.9 % 1.5 %
February 62.5 % 8.0 % 22.9 % 3.9 % 1.5 %
January 61.9 % 7.8 % 23.4 % 3.8 % 1.6 %
JavaScript Engine
• Google - Chrome - V8
• Mozila - FF – Spider Monkey
• Microsoft - IE - Chakra
• Apple – safari - SquirrelFish
Old New Browser Player
• Microsoft Edge (codenamed Spartan) is a web
browser under development by Microsoft.
The new var is let
let example
var arr1 = [];
for (var j = 0; j < 10; j++) {
arr1[j] = function () {
return j;
};
}
var arr1 = [];
for (var j = 0; j < 10; j++) {
(function (j) {
arr1[j] = function () {
return j;
};
})(j);
}
let arr = [];
for (let i = 0; i < 10; i++) {
arr[i] = function () {
return i;
};
}
Arrow Function
let square = x => x * x;
let add = (a, b) => a + b;
let pi = () => 3.1415;
console.log(square(5));
console.log(add(3, 4));
console.log(pi());
Arrow function example 1
Arrow Function
window.name = "Dog4";
function Dog(name){
this.name = name;
}
Dog.prototype.eat = function(){
setTimeout(function(){
console.log(`${this.name} eating`);
},300);
};
let d1 = new Dog('Dog1');
d1.eat();
window.name = "Dog4";
function Dog(name){
this.name = name;
}
Dog.prototype.eat = function(){
setTimeout(function(){
console.log(`${this.name} eating`);
}.bind(this),300);
};
let d2 = new Dog('Dog2');
d2.eat();
window.name = "Dog4";
function Dog(name){
this.name = name;
}
Dog.prototype.eat = function(){
setTimeout(() => {
console.log(`${this.name} eating`);
},300);
};
let d3 = new Dog('Dog3');
d3.eat();
Arrow function example 2
Class
// Animal constructor
function Animal(name) {
this.name = name;
}
// Adding walk method to Animal
Animal.prototype.walk = function () {
console.log(this.name + " is walking.");
};
// Dog constructor
function Dog(name, age) {
this.age = age;
// init Animal constructor
Animal.call(this, name);
}
// Inherit the Animal prototype (this create a copy of the prototype)
Dog.prototype = Object.create(Animal.prototype);
// Set the Dog constructor to 'Dog'
Dog.prototype.constructor = Dog;
var dog1 = new Dog("dog1", 3);
dog1.walk();
class Animal {
constructor(name) {
this.name = name;
}
walk() {
console.log(this.name + " is walking.");
}
}
class Dog extends Animal {
constructor(name,age) {
super(name); //call the parent method with super
this.age = age;
}
}
let dog1 = new Dog("dog1",3);
dog1.walk();
Class example
Class get and set
Class get, set example
class Person{
constructor(name){
this._name = name;
console.log(`${this._name} Created`);
}
run(){
console.log(`${this._name} is runing!`);
}
get name(){
console.log(`get this ${this._name} name`);
return this._name;
}
set name(name){
console.log(`set this ${name} name`);
this._name = name;
}
}
let p = new Person("ofir");
console.log(p.name);
p.name = "ofir fridman";
console.log(p.name);
Proxy
var p = new Proxy(target, handler);
let person = {
name: 'Ofir'
};
let handler = {
get: function (target, key) {
return `Hi ${target[key]}`;
}
};
person = new Proxy(person, handler);
console.log(person.name);
Get example 1
let person = {};
let handler = {
get: function (target, prop) {
if (prop in target) {
return target[prop];
}
target[prop] = new Proxy({}, handler);
return target[prop];
}
};
person = new Proxy(person, handler);
person.details.options.name = "ofir";
console.log(person.details.name);
Get example 2
*Note: current we can test it only in Firefox
Proxy
Set example
let person = {};
let handler = {
set: function (target, prop, value) {
if (prop === "id") {
throw new TypeError('You not allow to change id!!!');
}
if (prop === "age") {
if (!Number.isInteger(value)) {
throw new TypeError(`age should be integer. `);
}
}
if (prop === "name") {
target[prop] = value.charAt(0).toUpperCase() + value.slice(1);
}
}
};
person = new Proxy(person,handler);
person.name = "ofir";
console.log(person.name);
person.id = 123;
person.age = 12.2;
*Note: current we can test it only in Firefox
Iterators
Iterable
[1,2,n]
Iterator
next()
{value: 1, done: false}
{value: 2, done: false}
{value: n, done: false}
{value: n+1, done: true}
Example Iterators
let sum =0;
let numbers = [1,2,3,4];
let iterator = numbers.values();
let next = iterator.next();
while(!next.done){
sum += next.value;
next = iterator.next();
}
console.log(`sum = ${sum}`);
sum = 0;
for(let i of numbers){
sum += i;
}
console.log(`sum = ${sum}`);
ECMAScript 6 Features
• arrows
• classes
• enhanced object literals
• template strings
• destructuring
• default + rest + spread
• let + const
• iterators + for..of
• generators
• unicode
• modules
• module loaders
• map + set + weakmap + weakset
• proxies
• symbols
• subclassable built-ins
• promises
• math + number + string + array + object APIs
• binary and octal literals
• reflect api
• tail calls
ECMAScript 6 Browser Support
ECMAScript Playground
• ES6Fiddle
• BABEL
External links
Wikipedia
Brendan Eich
w3schools
Browser Statistics
JavaScript engine
You Tube
ECMAScript 6 - The Future is Here - Uri Shaked
ES6: A realistic use of proxies
MDN
Proxy
Classes
let
Arrow functions
Iterators and generators
Pluralsight
JavaScript Fundamentals for ES6
+ Slides
EcmaScript 6 Today! By Abdul Habrah
ECMAScript 6 with Kit Cambridge

More Related Content

What's hot

Smarter Testing with Spock
Smarter Testing with SpockSmarter Testing with Spock
Smarter Testing with Spock
Dmitry Voloshko
 

What's hot (20)

The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180
 
Gatling.pptx
Gatling.pptxGatling.pptx
Gatling.pptx
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
Smarter Testing with Spock
Smarter Testing with SpockSmarter Testing with Spock
Smarter Testing with Spock
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212
 
Object oriented JavaScript
Object oriented JavaScriptObject oriented JavaScript
Object oriented JavaScript
 
Lalal
LalalLalal
Lalal
 
Psycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptPsycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python Script
 
The Ring programming language version 1.5.4 book - Part 53 of 185
The Ring programming language version 1.5.4 book - Part 53 of 185The Ring programming language version 1.5.4 book - Part 53 of 185
The Ring programming language version 1.5.4 book - Part 53 of 185
 
Indexing & query optimization
Indexing & query optimizationIndexing & query optimization
Indexing & query optimization
 
Frege is a Haskell for the JVM
Frege is a Haskell for the JVMFrege is a Haskell for the JVM
Frege is a Haskell for the JVM
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To Test
 
Java 8 Puzzlers [as presented at OSCON 2016]
Java 8 Puzzlers [as presented at  OSCON 2016]Java 8 Puzzlers [as presented at  OSCON 2016]
Java 8 Puzzlers [as presented at OSCON 2016]
 
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189
 
Zen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst ApplicationsZen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst Applications
 

Viewers also liked

HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVG
yarcub
 

Viewers also liked (14)

HTML 5_Canvas
HTML 5_CanvasHTML 5_Canvas
HTML 5_Canvas
 
HTML 5 Canvas & SVG
HTML 5 Canvas & SVGHTML 5 Canvas & SVG
HTML 5 Canvas & SVG
 
Canvas - HTML 5
Canvas - HTML 5Canvas - HTML 5
Canvas - HTML 5
 
HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVG
 
Working With Canvas
Working With CanvasWorking With Canvas
Working With Canvas
 
HTML CANVAS
HTML CANVASHTML CANVAS
HTML CANVAS
 
Canvas & Charts
Canvas & ChartsCanvas & Charts
Canvas & Charts
 
Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browser
 
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
 HTML Canvas tips & tricks - Lightning Talk by Roman Rodych HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
 
【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)
 
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the Web
 
Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包
 
從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas
 

Similar to ES6

ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
qmmr
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your code
Laurence Svekis ✔
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
stasimus
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
Robert MacLean
 

Similar to ES6 (20)

ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your code
 
JavaScript in 2015
JavaScript in 2015JavaScript in 2015
JavaScript in 2015
 
Learnjs
LearnjsLearnjs
Learnjs
 
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...
 
Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leet
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Einführung in TypeScript
Einführung in TypeScriptEinführung in TypeScript
Einführung in TypeScript
 

Recently uploaded

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

ES6

  • 2. ME • Ofir Fridman • FE Developer • Love code, technology, sport
  • 3. JavaScript History • Beginnings at Netscape • JavaScript was originally developed by Brendan Eich, • The first version was completed in ten days • JavaScript first called Mocha, which was later renamed LiveScript in September 1995 and later JavaScript
  • 5. Browser Statistics 2015 Chrome IE Firefox Safari Opera April 63.9 % 8.0 % 21.6 % 3.8 % 1.5 % March 63.7 % 7.7 % 22.1 % 3.9 % 1.5 % February 62.5 % 8.0 % 22.9 % 3.9 % 1.5 % January 61.9 % 7.8 % 23.4 % 3.8 % 1.6 %
  • 6. JavaScript Engine • Google - Chrome - V8 • Mozila - FF – Spider Monkey • Microsoft - IE - Chakra • Apple – safari - SquirrelFish
  • 7.
  • 8. Old New Browser Player • Microsoft Edge (codenamed Spartan) is a web browser under development by Microsoft.
  • 9. The new var is let let example var arr1 = []; for (var j = 0; j < 10; j++) { arr1[j] = function () { return j; }; } var arr1 = []; for (var j = 0; j < 10; j++) { (function (j) { arr1[j] = function () { return j; }; })(j); } let arr = []; for (let i = 0; i < 10; i++) { arr[i] = function () { return i; }; }
  • 10. Arrow Function let square = x => x * x; let add = (a, b) => a + b; let pi = () => 3.1415; console.log(square(5)); console.log(add(3, 4)); console.log(pi()); Arrow function example 1
  • 11. Arrow Function window.name = "Dog4"; function Dog(name){ this.name = name; } Dog.prototype.eat = function(){ setTimeout(function(){ console.log(`${this.name} eating`); },300); }; let d1 = new Dog('Dog1'); d1.eat(); window.name = "Dog4"; function Dog(name){ this.name = name; } Dog.prototype.eat = function(){ setTimeout(function(){ console.log(`${this.name} eating`); }.bind(this),300); }; let d2 = new Dog('Dog2'); d2.eat(); window.name = "Dog4"; function Dog(name){ this.name = name; } Dog.prototype.eat = function(){ setTimeout(() => { console.log(`${this.name} eating`); },300); }; let d3 = new Dog('Dog3'); d3.eat(); Arrow function example 2
  • 12. Class // Animal constructor function Animal(name) { this.name = name; } // Adding walk method to Animal Animal.prototype.walk = function () { console.log(this.name + " is walking."); }; // Dog constructor function Dog(name, age) { this.age = age; // init Animal constructor Animal.call(this, name); } // Inherit the Animal prototype (this create a copy of the prototype) Dog.prototype = Object.create(Animal.prototype); // Set the Dog constructor to 'Dog' Dog.prototype.constructor = Dog; var dog1 = new Dog("dog1", 3); dog1.walk(); class Animal { constructor(name) { this.name = name; } walk() { console.log(this.name + " is walking."); } } class Dog extends Animal { constructor(name,age) { super(name); //call the parent method with super this.age = age; } } let dog1 = new Dog("dog1",3); dog1.walk(); Class example
  • 13. Class get and set Class get, set example class Person{ constructor(name){ this._name = name; console.log(`${this._name} Created`); } run(){ console.log(`${this._name} is runing!`); } get name(){ console.log(`get this ${this._name} name`); return this._name; } set name(name){ console.log(`set this ${name} name`); this._name = name; } } let p = new Person("ofir"); console.log(p.name); p.name = "ofir fridman"; console.log(p.name);
  • 14. Proxy var p = new Proxy(target, handler); let person = { name: 'Ofir' }; let handler = { get: function (target, key) { return `Hi ${target[key]}`; } }; person = new Proxy(person, handler); console.log(person.name); Get example 1 let person = {}; let handler = { get: function (target, prop) { if (prop in target) { return target[prop]; } target[prop] = new Proxy({}, handler); return target[prop]; } }; person = new Proxy(person, handler); person.details.options.name = "ofir"; console.log(person.details.name); Get example 2 *Note: current we can test it only in Firefox
  • 15. Proxy Set example let person = {}; let handler = { set: function (target, prop, value) { if (prop === "id") { throw new TypeError('You not allow to change id!!!'); } if (prop === "age") { if (!Number.isInteger(value)) { throw new TypeError(`age should be integer. `); } } if (prop === "name") { target[prop] = value.charAt(0).toUpperCase() + value.slice(1); } } }; person = new Proxy(person,handler); person.name = "ofir"; console.log(person.name); person.id = 123; person.age = 12.2; *Note: current we can test it only in Firefox
  • 16. Iterators Iterable [1,2,n] Iterator next() {value: 1, done: false} {value: 2, done: false} {value: n, done: false} {value: n+1, done: true} Example Iterators let sum =0; let numbers = [1,2,3,4]; let iterator = numbers.values(); let next = iterator.next(); while(!next.done){ sum += next.value; next = iterator.next(); } console.log(`sum = ${sum}`); sum = 0; for(let i of numbers){ sum += i; } console.log(`sum = ${sum}`);
  • 17. ECMAScript 6 Features • arrows • classes • enhanced object literals • template strings • destructuring • default + rest + spread • let + const • iterators + for..of • generators • unicode • modules • module loaders • map + set + weakmap + weakset • proxies • symbols • subclassable built-ins • promises • math + number + string + array + object APIs • binary and octal literals • reflect api • tail calls
  • 20. External links Wikipedia Brendan Eich w3schools Browser Statistics JavaScript engine You Tube ECMAScript 6 - The Future is Here - Uri Shaked ES6: A realistic use of proxies MDN Proxy Classes let Arrow functions Iterators and generators Pluralsight JavaScript Fundamentals for ES6 + Slides EcmaScript 6 Today! By Abdul Habrah ECMAScript 6 with Kit Cambridge