SlideShare a Scribd company logo
ES6
& The Future Of JS
Nenad Pečanac
Serengeti
Contents
1) History
2) Tooling
3) Syntax
4) Functions
5) Classes
6) Collections
7) Modules
8) Promises
9) The Future
1) History
History (1)
JavaScript was created in 1995 by Brendan Eich for Netscape.
It was developed as Mocha and released as LiveScript.
It was quickly renamed to JavaScript, as a
marketing move due to Java’s popularity.
New name caused a significant
misunderstanding of the language.
Language was created „in a week” and released incomplete.
Ambitious design influenced by Java, Perl, Scheme and Self.
History (2)
Microsoft released JScript for IE 3.0 in 1996.
Browser Wars: CSS, DOM, Scripting, Dynamic HTML ...
Netscape delivered JavaScript to Ecma International for
standardization in 1996.
ECMAScript was accepted as the compromised trade name.
History (3)
Release Year Changes
1 1997 First edition
2 1998
Editorial changes to keep the specification
fully aligned with ISO/IEC 16262
international standard
3 1999
Added regular expressions, better string
handling, new control statements, try/catch
exception handling, tighter definition of
errors, formatting for numeric output and
other enhancements
4 -
Abandoned due to political differences
concerning language complexity.
History (4)
Release Year Changes
5 2009
Adds strict mode, a subset intended to
provide more thorough error checking,
avoid error-prone constructs and clarifies
many ambiguities. Adds some new
features, such as getters and setters and
library support for JSON.
5.1 2011
Aligned with third edition of the ISO/IEC
16262:2011.
6 2015 ECMAScript Harmony or ES6 Harmony.
7 ... Work in progress.
Current browser support
http://kangax.github.io/compat-table/es6/
2) Tooling
Tooling
JS-to-JS transpiler is currently required to run ES6.
Transpiler compiles code from the latest version into older
versions of the language.
As browser support gets better
ES7 and ES8 will be transpilled
into ES6 and beyond.
Transpilers like Babel also provide
human-readable output.
3) Syntax
Let & Const
Let and const are alternatives to var when declaring variables.
Let is block-scoped instead of lexically scoped to a function.
Let is hoisted to the top of the block, while var declarations
are hoisted to top of the function.
for(let i = 0, l = list.length; i < l; i++) {
// do something with list[i]
}
console.log(i); // undefined
Let & Const
Const is also block-scoped, hoisted and must be initialized
Assigning to const after initialization fails silently
(or with an exception under strict mode).
const MY_CONSTANT = 1;
MY_CONSTANT = 2 // Error, attempt to change
const SOME_CONST; // Error, not initialized
Object properties can still be changed
const MY_OBJECT = {some: 1};
MY_OBJECT.some = 'body';
Template Strings
Template strings provide syntactic sugar for constructing
strings similar to string interpolation features in Perl, Python..
var text = (
`foo
bar
baz`)
var name = "Bob", time = "today";
`Hello ${name}, how are you ${time}?`
Destructuring
Destructuring provides binding using pattern matching,
with support for matching arrays and objects.
// Array matching
var list = [ 1, 2, 3 ]
var [ a, , b ] = list // a=1, b=3
[ b, a ] = [ a, b ] // a=3, b=1
// Object matching
var robotA = { name: "Bender" };
var robotB = { name: "Flexo" };
var { name: nameA } = robotA;
console.log(nameA); // "Bender„
var { name: nameB } = robotB;
console.log(nameB); // "Flexo"
// Fail-soft matching
var [missing] = [];
console.log(missing); // undefined
Object Literals
Object literals are extended with several new features:
var obj = {
// __proto__
__proto__: theProtoObj,
// Shorthand for ‘handler: handler’
handler,
// Methods
toString() {
// Super calls
return "d " + super.toString();
},
// Computed (dynamic) property names
[ 'prop_' + (() => 42)() ]: 42
};
4) Functions
Arrow Functions
Arrows are a function shorthand using the
param => return_value syntax:
// Expression bodies
var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
var pairs = evens.map(v => ({even: v, odd: v + 1}));
// Statement bodies
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
});
Arrow Functions
Arrow functions inherit THIS value from the enclosing scope:
this.nums.forEach((v) => {
if (v % 5 === 0)
this.fives.push(v)
})
In ES5 we have to use self/that trick:
var self = this;
this.nums.forEach(function (v) {
if (v % 5 === 0)
self.fives.push(v);
})
5) Classes
Classes (1)
ES6 classes are syntactic sugar over the
prototype-based OO pattern.
Classes are a well-debated feature of ES6.
Some believe that they go against the prototypal nature of
JavaScript, while others think they lower the entry barrier
for beginners and people coming from other languages.
Classes (2)
class Vehicle {
constructor(name) {
this.name = name;
this.kind = 'vehicle';
}
getName() {
return this.name;
}
}
// Create an instance
let myVehicle = new Vehicle('rocky');
6) Collections
Iterators
let fibonacci = {
[Symbol.iterator]() { // default iterator for an object.
let pre = 0, cur = 1;
return {
next() { // required method
[pre, cur] = [cur, pre + cur];
return { done: false, value: cur }
}
}
}
}
For .. of Loop
For .. of loop is new loop for all iterables.
It starts by calling the [Symbol.iterator]() method
which returns a new iterator object.
An iterator object can be any object with a next() method.
for (var n of fibonacci) {
// truncate the sequence at 1000
if (n > 1000)
break;
console.log(n);
}
Map + Set
// Maps
var m = new Map();
m.set("hello", 42);
m.set(s, 34);
m.get(s) == 34;
// Sets
var s = new Set();
s.add("hello").add("goodbye").add("hello");
s.size === 2;
s.has("hello") === true;
WeakMap + WeakSet
Weak collections allow GC collection of their keys.
// Weak Maps
var wm = new WeakMap();
wm.set(s, { extra: 42 });
wm.size === undefined
// Weak Collections are not enumerable and do not have size
// Weak Sets
var ws = new WeakSet();
ws.add({ data: 42 });
// If data has no other references, it can be GC collected
7) Modules
Modules (1)
Language-level support for modules for component definition.
Codifies patterns from AMD, CommonJS, RequireJS ...
Runtime behaviour defined by a host-defined default loader.
Implicitly async model – no code executes until requested
modules are available and processed.
Modules (2)
// lib/math.js
export function sum(x, y) {
return x + y;
}
export var pi = 3.141593;
// app.js
import * as math from "lib/math";
alert("2π = " + math.sum(math.pi, math.pi));
8) Promises
Promises
Promises are used for asynchronous programming.
Promises are first class representation of a value that may
be made available in the future.
It is a proxy for a value that will eventually become available.
Promises are used in many existing JavaScript libraries.
Promises
function resolveUnderThreeSeconds (delay) {
return new Promise(function (resolve, reject) {
setTimeout(resolve, delay);
// once a promise is settled, it’s result can’t change
setTimeout(reject, 3000);
})
}
resolveUnderThreeSeconds(2000); // resolves!
resolveUnderThreeSeconds(7000);
// fulfillment took so long, it was rejected.
9) The Future
Future releases (1)
ES7 is due 12 months after ES6.
TC39 (the ECMAScript standard committee)
is embracing 12 month release cycle.
New, naming convention:
ES6 = ES2015
ES7 = ES2016
ES8 = ES2017 ...
Completed features will be published once a year,
others will be scheduled for the next release.
Future releases (2)
„ECMAScript is a vibrant language and the evolution of the
language is not complete. Significant technical enhancement
will continue with future editions of this specification.”
... ES 5 specification
Future releases (3)
New proposed features for ES7:
• concurrency and atomics,
• zero-copy binary data transfer,
• number and math enhancements,
• observable streams,
• better metaprogramming with classes,
• class and instance properties,
• operator overloading,
• value types (first-class primitive-like objects),
• records, tuples, traits ...
The End
To be continued ...

More Related Content

What's hot

Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
Anton Keks
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
Anton Keks
 
Interfaces in JAVA !! why??
Interfaces in JAVA !!  why??Interfaces in JAVA !!  why??
Interfaces in JAVA !! why??
vedprakashrai
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
Vskills
 
Kotlin
KotlinKotlin
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & Encodings
Anton Keks
 
Byte code field report
Byte code field reportByte code field report
Byte code field report
Rafael Winterhalter
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvm
IndicThreads
 
(5) cpp abstractions essential_operators
(5) cpp abstractions essential_operators(5) cpp abstractions essential_operators
(5) cpp abstractions essential_operators
Nico Ludwig
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
Azul Systems Inc.
 
Java Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, AssertionsJava Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, Assertions
Anton Keks
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
Anton Keks
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic Proxies
Rafael Luque Leiva
 
Java
JavaJava
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
Miles Sabin
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 

What's hot (19)

Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
 
Interfaces in JAVA !! why??
Interfaces in JAVA !!  why??Interfaces in JAVA !!  why??
Interfaces in JAVA !! why??
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
 
Kotlin
KotlinKotlin
Kotlin
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & Encodings
 
Byte code field report
Byte code field reportByte code field report
Byte code field report
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvm
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
(5) cpp abstractions essential_operators
(5) cpp abstractions essential_operators(5) cpp abstractions essential_operators
(5) cpp abstractions essential_operators
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
 
Java Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, AssertionsJava Course 5: Enums, Generics, Assertions
Java Course 5: Enums, Generics, Assertions
 
JAVA BYTE CODE
JAVA BYTE CODEJAVA BYTE CODE
JAVA BYTE CODE
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic Proxies
 
Java
JavaJava
Java
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 

Viewers also liked

Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScriptRyo Maruyama
 
JavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, PerformanceJavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, Performance
クラスメソッド株式会社
 
kontainer-js
kontainer-jskontainer-js
kontainer-js
Kuu Miyazaki
 
JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6
Aayush Shrestha
 
150421 es6とかな話
150421 es6とかな話150421 es6とかな話
150421 es6とかな話
kotaro_hirayama
 
FileReader and canvas and server silde
FileReader and canvas and server sildeFileReader and canvas and server silde
FileReader and canvas and server silde
Net Kanayan
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめました
Net Kanayan
 
JavaScript.Next Returns
JavaScript.Next ReturnsJavaScript.Next Returns
JavaScript.Next Returns
dynamis
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
Mohd Saeed
 
はじめてのWallaby.js
はじめてのWallaby.jsはじめてのWallaby.js
はじめてのWallaby.js
Shunta Saito
 
Startup JavaScript
Startup JavaScriptStartup JavaScript
Startup JavaScript
Akinari Tsugo
 
ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)
taskie
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうkenji4569
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話
Junya Hayashi
 
Nds meetup8 lt
Nds meetup8 ltNds meetup8 lt
Nds meetup8 lt
ushiboy
 
アニメーションの実装つらい話
アニメーションの実装つらい話アニメーションの実装つらい話
アニメーションの実装つらい話
kata shin
 
Hello npm
Hello npmHello npm
Hello npm
Muyuu Fujita
 
Learn ES2015
Learn ES2015Learn ES2015
Learn ES2015
Muyuu Fujita
 
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Haraguchi Go
 

Viewers also liked (20)

Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScript
 
JavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, PerformanceJavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, Performance
 
kontainer-js
kontainer-jskontainer-js
kontainer-js
 
JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6
 
150421 es6とかな話
150421 es6とかな話150421 es6とかな話
150421 es6とかな話
 
FileReader and canvas and server silde
FileReader and canvas and server sildeFileReader and canvas and server silde
FileReader and canvas and server silde
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめました
 
JavaScript.Next Returns
JavaScript.Next ReturnsJavaScript.Next Returns
JavaScript.Next Returns
 
jQuery勉強会#4
jQuery勉強会#4jQuery勉強会#4
jQuery勉強会#4
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
 
はじめてのWallaby.js
はじめてのWallaby.jsはじめてのWallaby.js
はじめてのWallaby.js
 
Startup JavaScript
Startup JavaScriptStartup JavaScript
Startup JavaScript
 
ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろう
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話
 
Nds meetup8 lt
Nds meetup8 ltNds meetup8 lt
Nds meetup8 lt
 
アニメーションの実装つらい話
アニメーションの実装つらい話アニメーションの実装つらい話
アニメーションの実装つらい話
 
Hello npm
Hello npmHello npm
Hello npm
 
Learn ES2015
Learn ES2015Learn ES2015
Learn ES2015
 
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
 

Similar to ES6 - JavaCro 2016

Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
Sebastian Pederiva
 
Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !
Gaurav Behere
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
Felipe
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
Jady Yang
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
Vladimir Sedach
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
Ruslan Shevchenko
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
Samuel Abraham
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
React native
React nativeReact native
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
parveen837153
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
Jonathan Fine
 
The State of JavaScript
The State of JavaScriptThe State of JavaScript
The State of JavaScript
Domenic Denicola
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
Abdulsattar Mohammed
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
Ahmed Assaf
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
Sergey Bolshchikov
 
Java tut1
Java tut1Java tut1
Java tut1
Ajmal Khan
 

Similar to ES6 - JavaCro 2016 (20)

Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
jsbasics-slide
jsbasics-slidejsbasics-slide
jsbasics-slide
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
React native
React nativeReact native
React native
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
The State of JavaScript
The State of JavaScriptThe State of JavaScript
The State of JavaScript
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
 
Java
JavaJava
Java
 
Java tut1
Java tut1Java tut1
Java tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 

Recently uploaded

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 

Recently uploaded (20)

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 

ES6 - JavaCro 2016

  • 1. ES6 & The Future Of JS Nenad Pečanac Serengeti
  • 2. Contents 1) History 2) Tooling 3) Syntax 4) Functions 5) Classes 6) Collections 7) Modules 8) Promises 9) The Future
  • 4. History (1) JavaScript was created in 1995 by Brendan Eich for Netscape. It was developed as Mocha and released as LiveScript. It was quickly renamed to JavaScript, as a marketing move due to Java’s popularity. New name caused a significant misunderstanding of the language. Language was created „in a week” and released incomplete. Ambitious design influenced by Java, Perl, Scheme and Self.
  • 5. History (2) Microsoft released JScript for IE 3.0 in 1996. Browser Wars: CSS, DOM, Scripting, Dynamic HTML ... Netscape delivered JavaScript to Ecma International for standardization in 1996. ECMAScript was accepted as the compromised trade name.
  • 6. History (3) Release Year Changes 1 1997 First edition 2 1998 Editorial changes to keep the specification fully aligned with ISO/IEC 16262 international standard 3 1999 Added regular expressions, better string handling, new control statements, try/catch exception handling, tighter definition of errors, formatting for numeric output and other enhancements 4 - Abandoned due to political differences concerning language complexity.
  • 7. History (4) Release Year Changes 5 2009 Adds strict mode, a subset intended to provide more thorough error checking, avoid error-prone constructs and clarifies many ambiguities. Adds some new features, such as getters and setters and library support for JSON. 5.1 2011 Aligned with third edition of the ISO/IEC 16262:2011. 6 2015 ECMAScript Harmony or ES6 Harmony. 7 ... Work in progress.
  • 10. Tooling JS-to-JS transpiler is currently required to run ES6. Transpiler compiles code from the latest version into older versions of the language. As browser support gets better ES7 and ES8 will be transpilled into ES6 and beyond. Transpilers like Babel also provide human-readable output.
  • 12. Let & Const Let and const are alternatives to var when declaring variables. Let is block-scoped instead of lexically scoped to a function. Let is hoisted to the top of the block, while var declarations are hoisted to top of the function. for(let i = 0, l = list.length; i < l; i++) { // do something with list[i] } console.log(i); // undefined
  • 13. Let & Const Const is also block-scoped, hoisted and must be initialized Assigning to const after initialization fails silently (or with an exception under strict mode). const MY_CONSTANT = 1; MY_CONSTANT = 2 // Error, attempt to change const SOME_CONST; // Error, not initialized Object properties can still be changed const MY_OBJECT = {some: 1}; MY_OBJECT.some = 'body';
  • 14. Template Strings Template strings provide syntactic sugar for constructing strings similar to string interpolation features in Perl, Python.. var text = ( `foo bar baz`) var name = "Bob", time = "today"; `Hello ${name}, how are you ${time}?`
  • 15. Destructuring Destructuring provides binding using pattern matching, with support for matching arrays and objects. // Array matching var list = [ 1, 2, 3 ] var [ a, , b ] = list // a=1, b=3 [ b, a ] = [ a, b ] // a=3, b=1 // Object matching var robotA = { name: "Bender" }; var robotB = { name: "Flexo" }; var { name: nameA } = robotA; console.log(nameA); // "Bender„ var { name: nameB } = robotB; console.log(nameB); // "Flexo" // Fail-soft matching var [missing] = []; console.log(missing); // undefined
  • 16. Object Literals Object literals are extended with several new features: var obj = { // __proto__ __proto__: theProtoObj, // Shorthand for ‘handler: handler’ handler, // Methods toString() { // Super calls return "d " + super.toString(); }, // Computed (dynamic) property names [ 'prop_' + (() => 42)() ]: 42 };
  • 18. Arrow Functions Arrows are a function shorthand using the param => return_value syntax: // Expression bodies var odds = evens.map(v => v + 1); var nums = evens.map((v, i) => v + i); var pairs = evens.map(v => ({even: v, odd: v + 1})); // Statement bodies nums.forEach(v => { if (v % 5 === 0) fives.push(v); });
  • 19. Arrow Functions Arrow functions inherit THIS value from the enclosing scope: this.nums.forEach((v) => { if (v % 5 === 0) this.fives.push(v) }) In ES5 we have to use self/that trick: var self = this; this.nums.forEach(function (v) { if (v % 5 === 0) self.fives.push(v); })
  • 21. Classes (1) ES6 classes are syntactic sugar over the prototype-based OO pattern. Classes are a well-debated feature of ES6. Some believe that they go against the prototypal nature of JavaScript, while others think they lower the entry barrier for beginners and people coming from other languages.
  • 22. Classes (2) class Vehicle { constructor(name) { this.name = name; this.kind = 'vehicle'; } getName() { return this.name; } } // Create an instance let myVehicle = new Vehicle('rocky');
  • 24. Iterators let fibonacci = { [Symbol.iterator]() { // default iterator for an object. let pre = 0, cur = 1; return { next() { // required method [pre, cur] = [cur, pre + cur]; return { done: false, value: cur } } } } }
  • 25. For .. of Loop For .. of loop is new loop for all iterables. It starts by calling the [Symbol.iterator]() method which returns a new iterator object. An iterator object can be any object with a next() method. for (var n of fibonacci) { // truncate the sequence at 1000 if (n > 1000) break; console.log(n); }
  • 26. Map + Set // Maps var m = new Map(); m.set("hello", 42); m.set(s, 34); m.get(s) == 34; // Sets var s = new Set(); s.add("hello").add("goodbye").add("hello"); s.size === 2; s.has("hello") === true;
  • 27. WeakMap + WeakSet Weak collections allow GC collection of their keys. // Weak Maps var wm = new WeakMap(); wm.set(s, { extra: 42 }); wm.size === undefined // Weak Collections are not enumerable and do not have size // Weak Sets var ws = new WeakSet(); ws.add({ data: 42 }); // If data has no other references, it can be GC collected
  • 29. Modules (1) Language-level support for modules for component definition. Codifies patterns from AMD, CommonJS, RequireJS ... Runtime behaviour defined by a host-defined default loader. Implicitly async model – no code executes until requested modules are available and processed.
  • 30. Modules (2) // lib/math.js export function sum(x, y) { return x + y; } export var pi = 3.141593; // app.js import * as math from "lib/math"; alert("2π = " + math.sum(math.pi, math.pi));
  • 32. Promises Promises are used for asynchronous programming. Promises are first class representation of a value that may be made available in the future. It is a proxy for a value that will eventually become available. Promises are used in many existing JavaScript libraries.
  • 33. Promises function resolveUnderThreeSeconds (delay) { return new Promise(function (resolve, reject) { setTimeout(resolve, delay); // once a promise is settled, it’s result can’t change setTimeout(reject, 3000); }) } resolveUnderThreeSeconds(2000); // resolves! resolveUnderThreeSeconds(7000); // fulfillment took so long, it was rejected.
  • 35. Future releases (1) ES7 is due 12 months after ES6. TC39 (the ECMAScript standard committee) is embracing 12 month release cycle. New, naming convention: ES6 = ES2015 ES7 = ES2016 ES8 = ES2017 ... Completed features will be published once a year, others will be scheduled for the next release.
  • 36. Future releases (2) „ECMAScript is a vibrant language and the evolution of the language is not complete. Significant technical enhancement will continue with future editions of this specification.” ... ES 5 specification
  • 37. Future releases (3) New proposed features for ES7: • concurrency and atomics, • zero-copy binary data transfer, • number and math enhancements, • observable streams, • better metaprogramming with classes, • class and instance properties, • operator overloading, • value types (first-class primitive-like objects), • records, tuples, traits ...
  • 38. The End To be continued ...