SlideShare a Scribd company logo
1 of 19
Download to read offline
ES2015
Giacomo Zinetti
Giko
Block scoped variables
let a = 10;
{
let a = 20;
}
// a === 10;
var a = 10;
(function() {
var a = 20;
})();
// a === 10;
Block scoped variables
for (let i = 1; i <= 5; i++) {
item = document.createElement('li');
item.onclick = function(ev) {
console.log('Item ' + i);
};
}
for (var i = 1; i <= 5; i++) {
item = document.createElement('li');
(function(i) {
item.onclick = function(ev) {
console.log('Item ' + i);
};
})(i);
}
Constants
Object.defineProperty(window, "PI", {
value: 3.141593,
enumerable: true,
writable: false,
configurable: false
})
// Not block scoped
const PI = 3.141593;
PI = 6.022140;
TypeError: Assignment to constant variable.
// constant reference
const COLORS = {
good: 'green',
bad: 'red'
}
COLORS.good = 'yellow';
Arrow functions
const sum = (a, b) => a + b;
const square = a => a * a;
const theAnswer = () => 42;
var sum = function(a, b) {
return a + b
}
var square = function(a) {
return a * a;
}
var theAnswer = function() {
return 42;
}
Arrow function - Lexical scope
function Timer() {
this.counter = 0;
setInterval(() => {
this.counter++;
}, 1000);
}
let p = new Timer();
function Timer() {
var that = this;
this.counter = 0;
setInterval(function() {
that.counter++;
}, 1000);
}
var p = new Timer();
Default parameters
function next(x, step = 5) {
return x + step;
}
function next(x, step) {
step = step || 1;
return x + step;
}
Rest parameters
function f(x, y) {
var a = Array
.prototype
.slice
.call(arguments, 2);
};
function f(x, y, ...a) {
// a === [3, 4, 5]
}
f(1, 2, 3, 4, 5);
Spread operator
let args = [1, 2, 3, 4, 5];
function sum(...n) {
return n.reduce((a, b) => a + b, 0);
}
sum(...args);
let arr1 = [0, 1, 2];
let arr2 = [3, 4, 5];
let arr = [...arr1, ...arr2, 6];
var args = [1, 2, 3, 4, 5];
function sum() {
return Array.prototype.reduce
.call(arguments, function(a, b) {
return a + b;
}, 0);
}
sum.apply(null, args);
var arr1 = [0, 1, 2];
var arr2 = [3, 4, 5];
var arr = arr1.concat(arr2).concat(6);
let message = `
Hello ${name.toUpperCase()}!
Today is your ${age}th birthday
`;
Template Literals
var message =
"Hello " + name.toUpperCase() + "!n" +
"Today is your " + age + "th birthday";
Object literals
var o = {
name: name,
rename: function(newName) {
this.name = newName;
},
};
o["__" + name] = 42;
let o = {
name,
rename(newName) {
this.name = newName;
},
["__" + name]: 42,
};
Destructuring
let values = [1, 2];
let [a, b] = values;
const coords = () => ({x: 40, y: -35});
let {x, y} = coords();
var values = [1, 2];
let a = values[0], b = values[1];
function coords() {
return { x: 40, y: -35 };
}
var coord = coords();
var x = coord.x;
var y = coord.y;
Classes
class Timer {
constructor (time) {
this.time = time;
this.start();
}
start () {
// ...
}
}
var Timer = function (time) {
this.time = time;
this.start();
};
Timer.prototype.start = function() {
// ...
};
For - Of
let arr = [1, 2, 3, 4];
for (let e of arr) {
console.log(e);
}
var arr = [1, 2, 3, 4];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
New methods
[1, 3, 4].find(x => x > 2)
"<el></el>".repeat(3)
"hello".startsWith("he")
"hello".endsWith("lo")
"hello".includes("el")
Math.trunc(x)
Math.sign(x)
[1, 3, 4].filter(function (x) { return x > 2; })[0]
Array(3 + 1).join("<el></el>")
"hello".indexOf("he") === 0;
"hello".indexOf("lo") === ("hello".length - 2)
"hello".indexOf("el") !== -1;
(x < 0 ? Math.ceil(x) : Math.floor(x))
(x > 0 ? 1 : -1)
And so on… but we need more time
● Promises
● Generators
● Proxies
● Intl
● Symbols
● Maps and Sets
● Modules
● Tail call
Our friends
● Babel - https://babeljs.io/
● Caniuse - http://caniuse.com/
● http://kangax.github.io/compat-table/es6/
Grazie!
@giacomozinetti

More Related Content

What's hot

Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectHaqnawaz Ch
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++ Arun Nair
 
Object-oriented Javascript
Object-oriented JavascriptObject-oriented Javascript
Object-oriented JavascriptDaniel Ku
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervosoLuis Vendrame
 
Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanElaine Cecília Gatto
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperatorsSimon Proctor
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesOdoo
 
怖くない!Implicit!
怖くない!Implicit!怖くない!Implicit!
怖くない!Implicit!HonMarkHunt
 
computer graphics at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)Yasir Khan
 

What's hot (20)

C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final Project
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 
Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Finch + Finagle OAuth2
Finch + Finagle OAuth2Finch + Finagle OAuth2
Finch + Finagle OAuth2
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Object-oriented Javascript
Object-oriented JavascriptObject-oriented Javascript
Object-oriented Javascript
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - bean
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperators
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your Modules
 
怖くない!Implicit!
怖くない!Implicit!怖くない!Implicit!
怖くない!Implicit!
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
computer graphics at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)
 

Viewers also liked

Grids of Tomorrow: CSS Grid Layout
Grids of Tomorrow: CSS Grid LayoutGrids of Tomorrow: CSS Grid Layout
Grids of Tomorrow: CSS Grid LayoutSimone Lelli
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variablesGiacomo Zinetti
 
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Mary Ana Betancourt
 
Apresentação campanha 25 anos
Apresentação campanha 25 anosApresentação campanha 25 anos
Apresentação campanha 25 anosFabiano Dutra
 
Camera shots and sound
Camera shots and sound Camera shots and sound
Camera shots and sound banana81101
 
Технология переработки перьевых отходов.
Технология переработки перьевых отходов.Технология переработки перьевых отходов.
Технология переработки перьевых отходов.Danil Balykov
 
Planejamento de Trade Mkt | Karsten
Planejamento de Trade Mkt  | KarstenPlanejamento de Trade Mkt  | Karsten
Planejamento de Trade Mkt | KarstenJonas Jaeger
 
Help You Kick-start your Career as a Graphic Designer
Help You Kick-start your Career as a Graphic DesignerHelp You Kick-start your Career as a Graphic Designer
Help You Kick-start your Career as a Graphic DesignerDubSEO
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 

Viewers also liked (20)

CSS from the future
CSS from the futureCSS from the future
CSS from the future
 
Grids of Tomorrow: CSS Grid Layout
Grids of Tomorrow: CSS Grid LayoutGrids of Tomorrow: CSS Grid Layout
Grids of Tomorrow: CSS Grid Layout
 
CSS performance
CSS performanceCSS performance
CSS performance
 
Web performance & Http2
Web performance & Http2Web performance & Http2
Web performance & Http2
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variables
 
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
 
Apresentação campanha 25 anos
Apresentação campanha 25 anosApresentação campanha 25 anos
Apresentação campanha 25 anos
 
benny cv
benny cvbenny cv
benny cv
 
Maltrato animal.
Maltrato animal.Maltrato animal.
Maltrato animal.
 
Camera shots and sound
Camera shots and sound Camera shots and sound
Camera shots and sound
 
Технология переработки перьевых отходов.
Технология переработки перьевых отходов.Технология переработки перьевых отходов.
Технология переработки перьевых отходов.
 
14n61a01d5
14n61a01d514n61a01d5
14n61a01d5
 
король артур 27.01.17
король артур 27.01.17король артур 27.01.17
король артур 27.01.17
 
Planejamento de Trade Mkt | Karsten
Planejamento de Trade Mkt  | KarstenPlanejamento de Trade Mkt  | Karsten
Planejamento de Trade Mkt | Karsten
 
Почесні громадяни Сум
Почесні громадяни СумПочесні громадяни Сум
Почесні громадяни Сум
 
англійська для дітей
англійська  для дітейанглійська  для дітей
англійська для дітей
 
Міжнародний День сім'ї
Міжнародний День сім'їМіжнародний День сім'ї
Міжнародний День сім'ї
 
Церква Іллі
Церква ІлліЦерква Іллі
Церква Іллі
 
Help You Kick-start your Career as a Graphic Designer
Help You Kick-start your Career as a Graphic DesignerHelp You Kick-start your Career as a Graphic Designer
Help You Kick-start your Career as a Graphic Designer
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 

Similar to ES2015 New Features

JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)Aaron Gustafson
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays
 
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
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?장현 한
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairMark
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Tomasz Dziuda
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)Anders Jönsson
 

Similar to ES2015 New Features (20)

JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
JavaScript @ CTK
JavaScript @ CTKJavaScript @ CTK
JavaScript @ CTK
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
 
Wakanday JS201 Best Practices
Wakanday JS201 Best PracticesWakanday JS201 Best Practices
Wakanday JS201 Best Practices
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
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
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
Rust
RustRust
Rust
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
Introduccion a Jasmin
Introduccion a JasminIntroduccion a Jasmin
Introduccion a Jasmin
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
A Test of Strength
A Test of StrengthA Test of Strength
A Test of Strength
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 

Recently uploaded

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
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
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
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
 
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
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Recently uploaded (20)

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
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
 
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
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
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....
 
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
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

ES2015 New Features

  • 3. Block scoped variables let a = 10; { let a = 20; } // a === 10; var a = 10; (function() { var a = 20; })(); // a === 10;
  • 4. Block scoped variables for (let i = 1; i <= 5; i++) { item = document.createElement('li'); item.onclick = function(ev) { console.log('Item ' + i); }; } for (var i = 1; i <= 5; i++) { item = document.createElement('li'); (function(i) { item.onclick = function(ev) { console.log('Item ' + i); }; })(i); }
  • 5. Constants Object.defineProperty(window, "PI", { value: 3.141593, enumerable: true, writable: false, configurable: false }) // Not block scoped const PI = 3.141593; PI = 6.022140; TypeError: Assignment to constant variable. // constant reference const COLORS = { good: 'green', bad: 'red' } COLORS.good = 'yellow';
  • 6. Arrow functions const sum = (a, b) => a + b; const square = a => a * a; const theAnswer = () => 42; var sum = function(a, b) { return a + b } var square = function(a) { return a * a; } var theAnswer = function() { return 42; }
  • 7. Arrow function - Lexical scope function Timer() { this.counter = 0; setInterval(() => { this.counter++; }, 1000); } let p = new Timer(); function Timer() { var that = this; this.counter = 0; setInterval(function() { that.counter++; }, 1000); } var p = new Timer();
  • 8. Default parameters function next(x, step = 5) { return x + step; } function next(x, step) { step = step || 1; return x + step; }
  • 9. Rest parameters function f(x, y) { var a = Array .prototype .slice .call(arguments, 2); }; function f(x, y, ...a) { // a === [3, 4, 5] } f(1, 2, 3, 4, 5);
  • 10. Spread operator let args = [1, 2, 3, 4, 5]; function sum(...n) { return n.reduce((a, b) => a + b, 0); } sum(...args); let arr1 = [0, 1, 2]; let arr2 = [3, 4, 5]; let arr = [...arr1, ...arr2, 6]; var args = [1, 2, 3, 4, 5]; function sum() { return Array.prototype.reduce .call(arguments, function(a, b) { return a + b; }, 0); } sum.apply(null, args); var arr1 = [0, 1, 2]; var arr2 = [3, 4, 5]; var arr = arr1.concat(arr2).concat(6);
  • 11. let message = ` Hello ${name.toUpperCase()}! Today is your ${age}th birthday `; Template Literals var message = "Hello " + name.toUpperCase() + "!n" + "Today is your " + age + "th birthday";
  • 12. Object literals var o = { name: name, rename: function(newName) { this.name = newName; }, }; o["__" + name] = 42; let o = { name, rename(newName) { this.name = newName; }, ["__" + name]: 42, };
  • 13. Destructuring let values = [1, 2]; let [a, b] = values; const coords = () => ({x: 40, y: -35}); let {x, y} = coords(); var values = [1, 2]; let a = values[0], b = values[1]; function coords() { return { x: 40, y: -35 }; } var coord = coords(); var x = coord.x; var y = coord.y;
  • 14. Classes class Timer { constructor (time) { this.time = time; this.start(); } start () { // ... } } var Timer = function (time) { this.time = time; this.start(); }; Timer.prototype.start = function() { // ... };
  • 15. For - Of let arr = [1, 2, 3, 4]; for (let e of arr) { console.log(e); } var arr = [1, 2, 3, 4]; for (var i = 0; i < arr.length; i++) { console.log(arr[i]); }
  • 16. New methods [1, 3, 4].find(x => x > 2) "<el></el>".repeat(3) "hello".startsWith("he") "hello".endsWith("lo") "hello".includes("el") Math.trunc(x) Math.sign(x) [1, 3, 4].filter(function (x) { return x > 2; })[0] Array(3 + 1).join("<el></el>") "hello".indexOf("he") === 0; "hello".indexOf("lo") === ("hello".length - 2) "hello".indexOf("el") !== -1; (x < 0 ? Math.ceil(x) : Math.floor(x)) (x > 0 ? 1 : -1)
  • 17. And so on… but we need more time ● Promises ● Generators ● Proxies ● Intl ● Symbols ● Maps and Sets ● Modules ● Tail call
  • 18. Our friends ● Babel - https://babeljs.io/ ● Caniuse - http://caniuse.com/ ● http://kangax.github.io/compat-table/es6/