SlideShare uma empresa Scribd logo
1 de 38
EcmaScript 6
The Future Is Now
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.
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 ..
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.
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
Current browser support
http://kangax.github.io/compat-table/es6/
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 ...

Mais conteúdo relacionado

Mais procurados

Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
Behrad Zari
 

Mais procurados (20)

Java 8 concurrency abstractions
Java 8 concurrency abstractionsJava 8 concurrency abstractions
Java 8 concurrency abstractions
 
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Nashorn: JavaScript that doesn't suck - Tomer Gabel, WixNashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Machine learning with Apache Spark on Kubernetes | DevNation Tech Talk
Machine learning with Apache Spark on Kubernetes | DevNation Tech TalkMachine learning with Apache Spark on Kubernetes | DevNation Tech Talk
Machine learning with Apache Spark on Kubernetes | DevNation Tech Talk
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Logging in Scala
Logging in ScalaLogging in Scala
Logging in Scala
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Spring5 New Features
Spring5 New FeaturesSpring5 New Features
Spring5 New Features
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whale
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Introduction to Akka-Streams
Introduction to Akka-StreamsIntroduction to Akka-Streams
Introduction to Akka-Streams
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013
 
Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvm
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
 
Jan Stepien - Introducing structure in Clojure - Codemotion Milan 2017
Jan Stepien - Introducing structure in Clojure - Codemotion Milan 2017Jan Stepien - Introducing structure in Clojure - Codemotion Milan 2017
Jan Stepien - Introducing structure in Clojure - Codemotion Milan 2017
 

Destaque

Destaque (20)

Javantura v3 - The Internet of (Lego) Trains – Johan Janssen, Ingmar van der ...
Javantura v3 - The Internet of (Lego) Trains – Johan Janssen, Ingmar van der ...Javantura v3 - The Internet of (Lego) Trains – Johan Janssen, Ingmar van der ...
Javantura v3 - The Internet of (Lego) Trains – Johan Janssen, Ingmar van der ...
 
Javantura v3 - Just say it – using language to communicate with the computer ...
Javantura v3 - Just say it – using language to communicate with the computer ...Javantura v3 - Just say it – using language to communicate with the computer ...
Javantura v3 - Just say it – using language to communicate with the computer ...
 
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
Javantura v3 - Real-time BigData ingestion and querying of aggregated data – ...
 
Javantura v3 - Spring Boot under the hood– Nicolas Fränkel
Javantura v3 - Spring Boot under the hood– Nicolas FränkelJavantura v3 - Spring Boot under the hood– Nicolas Fränkel
Javantura v3 - Spring Boot under the hood– Nicolas Fränkel
 
Javantura v4 - Security architecture of the Java platform - Martin Toshev
Javantura v4 - Security architecture of the Java platform - Martin ToshevJavantura v4 - Security architecture of the Java platform - Martin Toshev
Javantura v4 - Security architecture of the Java platform - Martin Toshev
 
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko ŠmagucJavantura v4 - DMN – supplement your BPMN - Željko Šmaguc
Javantura v4 - DMN – supplement your BPMN - Željko Šmaguc
 
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin ToshevJavantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin Toshev
 
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko RoićJavantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
Javantura v4 - Let me tell you a story why Scrum is not for you - Roko Roić
 
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
Javantura v4 - The power of cloud in professional services company - Ivan Krn...Javantura v4 - The power of cloud in professional services company - Ivan Krn...
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
 
Javantura v4 - Test-driven documentation with Spring REST Docs - Danijel Mitar
Javantura v4 - Test-driven documentation with Spring REST Docs - Danijel MitarJavantura v4 - Test-driven documentation with Spring REST Docs - Danijel Mitar
Javantura v4 - Test-driven documentation with Spring REST Docs - Danijel Mitar
 
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
 
Javantura v4 - What’s NOT new in modular Java - Milen Dyankov
Javantura v4 - What’s NOT new in modular Java - Milen DyankovJavantura v4 - What’s NOT new in modular Java - Milen Dyankov
Javantura v4 - What’s NOT new in modular Java - Milen Dyankov
 
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
 
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. JuričJavantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
 
Javantura v4 - Android App Development in 2017 - Matej Vidaković
Javantura v4 - Android App Development in 2017 - Matej VidakovićJavantura v4 - Android App Development in 2017 - Matej Vidaković
Javantura v4 - Android App Development in 2017 - Matej Vidaković
 
Javantura v4 - Keycloak – instant login for your app - Marko Štrukelj
Javantura v4 - Keycloak – instant login for your app - Marko ŠtrukeljJavantura v4 - Keycloak – instant login for your app - Marko Štrukelj
Javantura v4 - Keycloak – instant login for your app - Marko Štrukelj
 
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
 
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko SrkočJavantura v4 - Getting started with Apache Spark - Dinko Srkoč
Javantura v4 - Getting started with Apache Spark - Dinko Srkoč
 

Semelhante a Javantura v3 - ES6 – Future Is Now – Nenad Pečanac

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 

Semelhante a Javantura v3 - ES6 – Future Is Now – Nenad Pečanac (20)

ES6 - JavaCro 2016
ES6 - JavaCro 2016ES6 - JavaCro 2016
ES6 - JavaCro 2016
 
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
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
React native
React nativeReact native
React native
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
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
 
jsbasics-slide
jsbasics-slidejsbasics-slide
jsbasics-slide
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 

Mais de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association

Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 

Mais de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20)

Java cro'21 the best tools for java developers in 2021 - hujak
Java cro'21   the best tools for java developers in 2021 - hujakJava cro'21   the best tools for java developers in 2021 - hujak
Java cro'21 the best tools for java developers in 2021 - hujak
 
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK KeynoteJavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
 
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan LozićJavantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
 
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
 
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander RadovanJavantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
 
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
 
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
 
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
 
Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
 
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
 
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
 
Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...
 
Javantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela PetracJavantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela Petrac
 
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje RuhekJavantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario KusekJavantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Javantura v3 - ES6 – Future Is Now – Nenad Pečanac

  • 1. EcmaScript 6 The Future Is Now 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.
  • 9. 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.
  • 11. 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
  • 12. 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';
  • 13. 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}?`
  • 14. 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
  • 15. 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 };
  • 17. 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); });
  • 18. 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); })
  • 20. 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.
  • 21. Classes (2) class Vehicle { constructor(name) { this.name = name; this.kind = 'vehicle'; } getName() { return this.name; } } // Create an instance let myVehicle = new Vehicle('rocky');
  • 23. 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 } } } } }
  • 24. 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); }
  • 25. 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;
  • 26. 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
  • 28. Modules (1) Language-level support for modules for component definition. Codifies patterns from AMD, CommonJS .. Runtime behaviour defined by a host-defined default loader. Implicitly async model – no code executes until requested modules are available and processed.
  • 29. 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));
  • 31. Promises Promises are used for asynchronous programming. Promises are first class representation of a value that may be made available in the future. Promises are used in many existing JavaScript libraries.
  • 32. 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 ...