SlideShare a Scribd company logo
1 of 24
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
SELA DEVELOPER PRACTICE
June 29-July 3, 2014
Ran Wahle
What’s new in ECMAScript 6
var links = document.querySelectorAll(“a”);
for (var i = 0; i < links.length; i++)
{
links[i].onclick = function(){alert(i);};
}
Warmup- what’s wrong with this code
var links = document.querySelectorAll(“a”);
for (var i = 0; i < links.length; i++)
{
var clickFunc = function(j) {
links[j].onclick = function(){alert(j);};
}(i);
}
Warmup- fix the wrong code (v5)
var links = document.querySelectorAll("a");
for (var i = 0; i < links.length; i++)
{
let j = i;
links[j].onclick = function(){alert(j);};
}
Fix the code (v6)
Syntactic Sugar
Promises
Modules & Classes
Platform support
Summary
Agenda
var firstName = ‘Ran’;
var lastName = ‘Wahle’;
//ES5
var person = {firstName: firstName, lastName: lastName};
//ES6
var person = {firstName, lastName};
Syntactic sugars: Shorthand objects
var {firstName, lastName} = person;
//firstName === ‘Ran’
//lastName === ‘Wahle’
Syntactic Sugar : Object destructure
var phoneParts = /^(d{3})-(d{2})-(d{7})$/.exec("972-54-
3050897");
var countryCode = phoneParts[0];
var areaCode = phoneParts[1];
var local = phoneParts[2];
console.log("countryCode", countryCode);
console.log("areaCode", areaCode);
console.log("local", local);
Desctructure: extract from array
var [,countryCode, areaCode, local] = /^(d{3})-(d{2})-
(d{7})$/.exec("972-54-3050897");
console.log("countryCode", countryCode);
console.log("areaCode", areaCode);
console.log("local", local);
Destructure of Array
var family= { father: {firstName: 'Dan', lastName: 'Wahle'} ,
mother: {firstName: 'Nira', lastName: 'Wahle'},
children: [
{firstName: 'Ran', lastName: 'Wahle'},
{firstName: 'Ayala', lastName: 'Fridman'},
{firstName: 'Tamar',lastName: 'Wahle'},
{firstName: 'Yair', lastName: 'Wahle'},
{firstName: 'Giyora', lastName: 'Wahle'},
{firstName: 'Amnon', lastName: 'Wahle'}
] }
//Query the first name of the family’s oldest child
var {'children': [{'firstName': name}]} = family;
console.log(name)
Nested objects destructure
var functionWithDefault = function(param1 = “val1”)
{
console.log(param1);
};
functionWithDefault();
//Ouputs : “val1”
Syntactic Sugar: Default parameters
var functionWithParameterCollection = function(paramA, paramB,
...theRest)
{
console.log(theRest);
};
functionWithParameterCollection ('a','b','c','d','e');
//output ["c", "d", "e"]
Syntactic sugar: parameters collection
var array = [1,2,3,4,5,6];
//es5
array.forEach(function(a) {console.log(a);});
//es6
array.forEach(a => console.log(a));
Arrow functions (lambda expression)
var promise = new Promise(
function(resolve, reject)
{
var request = new XMLHttpRequest();
request.open('GET', ‘/', true);
request.onreadystatechange = () =>
{resolve(request.response);
};
request.send();
}
).then(result =>
{console.log("Result", result, "Promise", promise);},
error =>
{console.error("Promise error", error);});
Promises (no q.js library involved)
var numbers = [1,2,3,4,5,6];
var squares = [x*x for (x of numbers)];
//query the array
var evens = [number for (number of numbers)
if (number % 2 === 0)]
console.log(numbers, squares, evens);
//output
[1, 2, 3, 4, 5, 6] [1, 4, 9, 16, 25, 36] [2, 4, 6]
Build array from another array
class Vehicle {
constructor( name, year ) {
this.name = name;
this.year = year;
}
summary() {
return "This vehicle's name is " + this.name + " and it
was manufactured in " + this.year;
}
}
var myCar = new Vehicle(‘Susita’, 1975);
Classes
Example from Daniel Struk’s blog http://dstrunk.com/ecmascript-6-features-classes/
class SemiTruck extends Vehicle {
constructor( x, y ) {
super( x, y );
this.wheels = 18;
}
}
Inherritence
Example from Daniel Struk’s blog http://dstrunk.com/ecmascript-6-features-classes/
Demo
Classes demo using Traceur
Modules
AMD implementation without libraries
No need to wrap an entire code in a function
Export
var innerResult = 0;
var addition = function(number)
{
console.log(typeof number, typeof innerResult);
innerResult = innerResult + number;
if (isNaN(innerResult))
{
innerResult = 0;
}
return innerResult;
};
//Export
export {addition};
Import
import {addition} from 'calculator';
document.querySelector('#btnAdd').onclick = function()
{
var number =
parseInt(document.querySelector('#txtNumber').value);
document.querySelector('#spnResult').innerText =
addition(number);
}
Demo
Very simple Calculator
Platform support
See http://kangax.github.io/compat-table/es6/ for updates
ECMAScript 6 has many features
Many of them are already implemented
in various libraries
Its standards are still in process
Many platforms not yet supports it
Summary
Questions
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
Thank You
http://blogs.Microsoft.co.il/ranw
Twitter: @ranwahle
ranw@sela.co.il

More Related Content

What's hot

Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Claire Townend Gee
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actorsbloodredsun
 
Automated code audits
Automated code auditsAutomated code audits
Automated code auditsDamien Seguy
 
Documentation Inference for Exceptions
Documentation Inference for ExceptionsDocumentation Inference for Exceptions
Documentation Inference for ExceptionsRay Buse
 

What's hot (6)

Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actors
 
SPARQLing cocktails
SPARQLing cocktailsSPARQLing cocktails
SPARQLing cocktails
 
Automated code audits
Automated code auditsAutomated code audits
Automated code audits
 
Angular mix chrisnoring
Angular mix chrisnoringAngular mix chrisnoring
Angular mix chrisnoring
 
Documentation Inference for Exceptions
Documentation Inference for ExceptionsDocumentation Inference for Exceptions
Documentation Inference for Exceptions
 

Similar to What's new in ECMAScript 6

More than syntax
More than syntaxMore than syntax
More than syntaxWooga
 
What's New in JavaScript
What's New in JavaScriptWhat's New in JavaScript
What's New in JavaScriptDan Cohn
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Lukas Ruebbelke
 
Ecmascript 2015 – best of new features()
Ecmascript 2015 – best of new features()Ecmascript 2015 – best of new features()
Ecmascript 2015 – best of new features()Miłosz Sobczak
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
 
JavaScript for Web Analysts
JavaScript for Web AnalystsJavaScript for Web Analysts
JavaScript for Web AnalystsLukáš Čech
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineMovel
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowKrzysztof Szafranek
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScriptJohannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScriptJohannes Hoppe
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascriptcrgwbr
 
PHPunit and you
PHPunit and youPHPunit and you
PHPunit and youmarkstory
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveNaresha K
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation JavascriptRamesh Nair
 
Testing for software engineers
Testing for software engineersTesting for software engineers
Testing for software engineersMohammed Ashour
 
Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009tolmasky
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 SimplifiedCarlos Ble
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerNic Raboy
 

Similar to What's new in ECMAScript 6 (20)

Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
More than syntax
More than syntaxMore than syntax
More than syntax
 
What's New in JavaScript
What's New in JavaScriptWhat's New in JavaScript
What's New in JavaScript
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Ecmascript 2015 – best of new features()
Ecmascript 2015 – best of new features()Ecmascript 2015 – best of new features()
Ecmascript 2015 – best of new features()
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
JavaScript for Web Analysts
JavaScript for Web AnalystsJavaScript for Web Analysts
JavaScript for Web Analysts
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascript
 
PHPunit and you
PHPunit and youPHPunit and you
PHPunit and you
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and Effective
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Testing for software engineers
Testing for software engineersTesting for software engineers
Testing for software engineers
 
Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 

More from Ran Wahle

MicroFrontend With Iframes, dirty laundry that can be cleaned
MicroFrontend With Iframes, dirty laundry that can be cleanedMicroFrontend With Iframes, dirty laundry that can be cleaned
MicroFrontend With Iframes, dirty laundry that can be cleanedRan Wahle
 
Into React-DOM.pptx
Into React-DOM.pptxInto React-DOM.pptx
Into React-DOM.pptxRan Wahle
 
Lets go to the background
Lets go to the backgroundLets go to the background
Lets go to the backgroundRan Wahle
 
Permissions api
Permissions apiPermissions api
Permissions apiRan Wahle
 
Lets go vanilla
Lets go vanillaLets go vanilla
Lets go vanillaRan Wahle
 
Custom elements
Custom elements Custom elements
Custom elements Ran Wahle
 
Web workers
Web workers Web workers
Web workers Ran Wahle
 
Using legacy code with micro frontends
Using legacy code with micro frontendsUsing legacy code with micro frontends
Using legacy code with micro frontendsRan Wahle
 
Ngrx one-effect
Ngrx one-effectNgrx one-effect
Ngrx one-effectRan Wahle
 
Angular migration
Angular migrationAngular migration
Angular migrationRan Wahle
 
Javascript async / await Frontend-IL
Javascript async / await Frontend-ILJavascript async / await Frontend-IL
Javascript async / await Frontend-ILRan Wahle
 
Boost js state management
Boost js state managementBoost js state management
Boost js state managementRan Wahle
 
Angular 2.0 change detection
Angular 2.0 change detectionAngular 2.0 change detection
Angular 2.0 change detectionRan Wahle
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Ran Wahle
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascriptRan Wahle
 
Angular js 2
Angular js 2Angular js 2
Angular js 2Ran Wahle
 
Asyncawait in typescript
Asyncawait in typescriptAsyncawait in typescript
Asyncawait in typescriptRan Wahle
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Ran Wahle
 
What’s new in angular 2 - From FrontEnd IL Meetup
What’s new in angular 2 - From FrontEnd IL MeetupWhat’s new in angular 2 - From FrontEnd IL Meetup
What’s new in angular 2 - From FrontEnd IL MeetupRan Wahle
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 

More from Ran Wahle (20)

MicroFrontend With Iframes, dirty laundry that can be cleaned
MicroFrontend With Iframes, dirty laundry that can be cleanedMicroFrontend With Iframes, dirty laundry that can be cleaned
MicroFrontend With Iframes, dirty laundry that can be cleaned
 
Into React-DOM.pptx
Into React-DOM.pptxInto React-DOM.pptx
Into React-DOM.pptx
 
Lets go to the background
Lets go to the backgroundLets go to the background
Lets go to the background
 
Permissions api
Permissions apiPermissions api
Permissions api
 
Lets go vanilla
Lets go vanillaLets go vanilla
Lets go vanilla
 
Custom elements
Custom elements Custom elements
Custom elements
 
Web workers
Web workers Web workers
Web workers
 
Using legacy code with micro frontends
Using legacy code with micro frontendsUsing legacy code with micro frontends
Using legacy code with micro frontends
 
Ngrx one-effect
Ngrx one-effectNgrx one-effect
Ngrx one-effect
 
Angular migration
Angular migrationAngular migration
Angular migration
 
Javascript async / await Frontend-IL
Javascript async / await Frontend-ILJavascript async / await Frontend-IL
Javascript async / await Frontend-IL
 
Boost js state management
Boost js state managementBoost js state management
Boost js state management
 
Angular 2.0 change detection
Angular 2.0 change detectionAngular 2.0 change detection
Angular 2.0 change detection
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0
 
Async patterns in javascript
Async patterns in javascriptAsync patterns in javascript
Async patterns in javascript
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
 
Asyncawait in typescript
Asyncawait in typescriptAsyncawait in typescript
Asyncawait in typescript
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Angular%201%20to%20angular%202
Angular%201%20to%20angular%202
 
What’s new in angular 2 - From FrontEnd IL Meetup
What’s new in angular 2 - From FrontEnd IL MeetupWhat’s new in angular 2 - From FrontEnd IL Meetup
What’s new in angular 2 - From FrontEnd IL Meetup
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 

Recently uploaded

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 

Recently uploaded (20)

Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 

What's new in ECMAScript 6

  • 1. © Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com SELA DEVELOPER PRACTICE June 29-July 3, 2014 Ran Wahle What’s new in ECMAScript 6
  • 2. var links = document.querySelectorAll(“a”); for (var i = 0; i < links.length; i++) { links[i].onclick = function(){alert(i);}; } Warmup- what’s wrong with this code
  • 3. var links = document.querySelectorAll(“a”); for (var i = 0; i < links.length; i++) { var clickFunc = function(j) { links[j].onclick = function(){alert(j);}; }(i); } Warmup- fix the wrong code (v5)
  • 4. var links = document.querySelectorAll("a"); for (var i = 0; i < links.length; i++) { let j = i; links[j].onclick = function(){alert(j);}; } Fix the code (v6)
  • 5. Syntactic Sugar Promises Modules & Classes Platform support Summary Agenda
  • 6. var firstName = ‘Ran’; var lastName = ‘Wahle’; //ES5 var person = {firstName: firstName, lastName: lastName}; //ES6 var person = {firstName, lastName}; Syntactic sugars: Shorthand objects
  • 7. var {firstName, lastName} = person; //firstName === ‘Ran’ //lastName === ‘Wahle’ Syntactic Sugar : Object destructure
  • 8. var phoneParts = /^(d{3})-(d{2})-(d{7})$/.exec("972-54- 3050897"); var countryCode = phoneParts[0]; var areaCode = phoneParts[1]; var local = phoneParts[2]; console.log("countryCode", countryCode); console.log("areaCode", areaCode); console.log("local", local); Desctructure: extract from array
  • 9. var [,countryCode, areaCode, local] = /^(d{3})-(d{2})- (d{7})$/.exec("972-54-3050897"); console.log("countryCode", countryCode); console.log("areaCode", areaCode); console.log("local", local); Destructure of Array
  • 10. var family= { father: {firstName: 'Dan', lastName: 'Wahle'} , mother: {firstName: 'Nira', lastName: 'Wahle'}, children: [ {firstName: 'Ran', lastName: 'Wahle'}, {firstName: 'Ayala', lastName: 'Fridman'}, {firstName: 'Tamar',lastName: 'Wahle'}, {firstName: 'Yair', lastName: 'Wahle'}, {firstName: 'Giyora', lastName: 'Wahle'}, {firstName: 'Amnon', lastName: 'Wahle'} ] } //Query the first name of the family’s oldest child var {'children': [{'firstName': name}]} = family; console.log(name) Nested objects destructure
  • 11. var functionWithDefault = function(param1 = “val1”) { console.log(param1); }; functionWithDefault(); //Ouputs : “val1” Syntactic Sugar: Default parameters
  • 12. var functionWithParameterCollection = function(paramA, paramB, ...theRest) { console.log(theRest); }; functionWithParameterCollection ('a','b','c','d','e'); //output ["c", "d", "e"] Syntactic sugar: parameters collection
  • 13. var array = [1,2,3,4,5,6]; //es5 array.forEach(function(a) {console.log(a);}); //es6 array.forEach(a => console.log(a)); Arrow functions (lambda expression)
  • 14. var promise = new Promise( function(resolve, reject) { var request = new XMLHttpRequest(); request.open('GET', ‘/', true); request.onreadystatechange = () => {resolve(request.response); }; request.send(); } ).then(result => {console.log("Result", result, "Promise", promise);}, error => {console.error("Promise error", error);}); Promises (no q.js library involved)
  • 15. var numbers = [1,2,3,4,5,6]; var squares = [x*x for (x of numbers)]; //query the array var evens = [number for (number of numbers) if (number % 2 === 0)] console.log(numbers, squares, evens); //output [1, 2, 3, 4, 5, 6] [1, 4, 9, 16, 25, 36] [2, 4, 6] Build array from another array
  • 16. class Vehicle { constructor( name, year ) { this.name = name; this.year = year; } summary() { return "This vehicle's name is " + this.name + " and it was manufactured in " + this.year; } } var myCar = new Vehicle(‘Susita’, 1975); Classes Example from Daniel Struk’s blog http://dstrunk.com/ecmascript-6-features-classes/
  • 17. class SemiTruck extends Vehicle { constructor( x, y ) { super( x, y ); this.wheels = 18; } } Inherritence Example from Daniel Struk’s blog http://dstrunk.com/ecmascript-6-features-classes/
  • 19. Modules AMD implementation without libraries No need to wrap an entire code in a function Export var innerResult = 0; var addition = function(number) { console.log(typeof number, typeof innerResult); innerResult = innerResult + number; if (isNaN(innerResult)) { innerResult = 0; } return innerResult; }; //Export export {addition}; Import import {addition} from 'calculator'; document.querySelector('#btnAdd').onclick = function() { var number = parseInt(document.querySelector('#txtNumber').value); document.querySelector('#spnResult').innerText = addition(number); }
  • 22. ECMAScript 6 has many features Many of them are already implemented in various libraries Its standards are still in process Many platforms not yet supports it Summary
  • 24. © Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com Thank You http://blogs.Microsoft.co.il/ranw Twitter: @ranwahle ranw@sela.co.il