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

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 180Mahmoud Samir Fayed
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014Henning Jacobs
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful weddingStéphane Wirtel
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?Ben Hall
 
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 181Mahmoud Samir Fayed
 
Smarter Testing with Spock
Smarter Testing with SpockSmarter Testing with Spock
Smarter Testing with SpockDmitry Voloshko
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
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 212Mahmoud Samir Fayed
 
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 ScriptSurvey Department
 
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 185Mahmoud Samir Fayed
 
Indexing & query optimization
Indexing & query optimizationIndexing & query optimization
Indexing & query optimizationJared Rosoff
 
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 JVMjwausle
 
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 TestHoward Lewis Ship
 
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]Baruch Sadogursky
 
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 189Mahmoud Samir Fayed
 
Zen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst ApplicationsZen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst ApplicationsJay Shirley
 

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 SVGyarcub
 
Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browsertec
 
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 RodychPivorak MeetUp
 
【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率NIED
 
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)Peter Lubbers
 
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 WebRobin Hawkes
 
Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Anna Su
 
從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 CanvasAnna Su
 

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
ECMAScript2015qmmr
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript FunctionsBrian Moschel
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The LandingHaci Murat Yaman
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairMark
 
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 codeLaurence Svekis ✔
 
JavaScript in 2015
JavaScript in 2015JavaScript in 2015
JavaScript in 2015Igor Laborie
 
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...Tim Chaplin
 
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 6Moaid Hathot
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptMichael Girouard
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Codestasimus
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leetjohndaviddalton
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven PractisesRobert MacLean
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionHans Höchtl
 

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

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 CVKhem
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
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
 
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
 
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?Antenna Manufacturer Coco
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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 Processorsdebabhi2
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
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...
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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
 
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
 
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?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 

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