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

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 

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/