SlideShare a Scribd company logo
Introduction into ES6 JavaScript.
AGENDA
@boyney123
Promises
Arrow functions
Consts
Let
Modules
StringTemplates
Destructuring
Parameters
Classes
Transpilation
Enhanced Object Literals
WHO'S USING ES6?
@boyney123
HOW CAN I USE ES6
@boyney123
https://kangax.github.io/compat-table/es6/
HOW CAN WE USE ES6 TODAY?
@boyney123
TRANSPILATION
@boyney123
ES6 : TRANSPILATION
Traceur
TypeScript
@boyney123
@boyney123
WHOS USING BABELJS
@boyney123
ES6 : LET
LET
@boyney123
The let statement declares a block scope local variable, optionally initializing it to a value.
if (x > y) {
let gamma = 12.7 + y;
i = gamma * x;
}
let allows you to declare variables that are limited in scope to the block,
statement, or expression on which it is used.This is unlike the var keyword,
which defines a variable globally, or locally to an entire function regardless of
block scope.
ES6 : LET
@boyney123
ES6 : LET - CODE EXAMPLES
@boyney123
ES6 : LET
CONST
@boyney123
The const declaration creates a read-only reference to a value. It does not mean the value it
holds is immutable, just that the variable identifier cannot be reassigned.
const API_URL = “http://www.some-api-url.co.uk”;
ES6 : CONST
@boyney123
ES6 : CONST - CODE EXAMPLES
@boyney123
ES6 : LET
MODULES
@boyney123
ES6 : MODULES
COMMONJS AMD
var $ = require('jquery');
exports.myExample = function () {};
define(['jquery'] , function ($) {
return function () {};
});
Common on browserCommon on server
The goal for ECMAScript 6 modules was to create a format that
both users of CommonJS and of AMD are happy with.
@boyney123
Named Exports - Several per module
ES6 : TYPES OF MODULES
Default Exports - One per module
@boyney123
ES6 : MODULES - CODE EXAMPLES
@boyney123
CLASSES
@boyney123
Syntactical sugar over JavaScript's existing prototype-based inheritance.The class
syntax is not introducing a new object-oriented inheritance model to JavaScript.
JavaScript classes provide a much simpler and clearer syntax to create objects and
deal with inheritance.
class Person {
constructor(firstname, surname) {
this.firstname = firstname;
this.surname = surname;
}
}
To declare a class, you use the class keyword with the name of the class ("Person" here).
ES6 : CLASSES
@boyney123
ES6 : CLASSES - CODE EXAMPLES
@boyney123
ES6 : LET
OBJECT
@boyney123
var obj = {
// Shorthand for ‘handler: handler’
handler,
// Methods
toString() {
// Super calls
return "d " + super.toString();
},
//get property
get property() {},
//set property
set property(value) {},
// Computed (dynamic) property names
[ 'prop_' + (() => 42)() ]: 42
};
ES6 : OBJECT
@boyney123
In JavaScript, parameters of functions default to undefined. However, in some
situations it might be useful to set a different default value.This is where default
parameters can help.
function multiply(a, b) {
b = typeof b !== 'undefined' ? b : 1;
return a*b;
}
multiply(5); // 5
ES6 : DEFAULT PARAMETERS
function multiply(a, b = 1) {
return a*b;
}
multiply(5); // 5
ES5 example
ES6 example
@boyney123
ES6 : LET
ARROW FUNCTIONS
@boyney123
An arrow function expression (also known as fat arrow function) has a shorter
syntax compared to function expressions and lexically binds the this value (does
not bind its own this, arguments, super, or new.target).
Arrow functions are always anonymous.
var a = [
"Hydrogen",
"Helium",
"Lithium",
"Beryllium"
];
var a2 = a.map(function(s){ return s.length });
var a3 = a.map( s => s.length );
ES6 : ARROW FUNCTIONS
Until arrow functions, every new function defined its own this value
@boyney123
ES6 : ARROW FUNCTIONS - CODE EXAMPLES
@boyney123
ES6 : LET
PROMISES
@boyney123
The Promise object is used for deferred and asynchronous computations.A
Promise represents an operation that hasn't completed yet, but is expected in the
future.
ES6 : PROMISES
Promise has three states:
pending: initial state, not fulfilled or rejected.
fulfilled: meaning that the operation completed successfully.
rejected: meaning that the operation failed.
@boyney123
ES6 : PROMISE LIFE CYCLE
@boyney123
ES6 : PROMISES - CODE EXAMPLES
@boyney123
ES6 : LET
TEMPLATE STRINGS
@boyney123
Template strings are string literals allowing embedded expressions.You can use
multi-line strings and string interpolation features with them.
`Hello World!`
`Hello brown bag!
I cant wait for a few drinks and dance on thursday!`
let person = ‘David’;
`${person} is drunk. Send him home!`
ES6 : TEMPLATE STRINGS
var person = ‘David’;
person + ‘ is drunk. Send him home!’ ES5 example
ES6 example
EVEN MORE ES6…
@boyney123
Introduction into ES6 JavaScript.
@boyney123
ES6 : LET
ASYNC
@boyney123
async keyword ensures that the function will return a Promise object.
Within an async function any time you return a value it will actually return a
promise that is resolved. If you want to reject you need to throw an error
async function foo() {
if( Math.round(Math.random()) )
return 'Success!';
else
throw 'Failure!';
}
ES7 : ASYNC
ES7 example
function foo() {
if( Math.round(Math.random()) )
return Promise.resolve('Success!');
else
return Promise.reject('Failure!');
} ES6 example
@boyney123
ES6 : LET
AWAIT
@boyney123
await will stop the function call until the async has resolved or rejected.
async function loadStory() {
try {
let story = await getJSON(‘story.json');
return story;
} catch (err) {
throw ‘Failure!';
}
}
ES7 : AWAIT
@boyney123
let db = new PouchDB(‘mydb');
try {
//nice that we don't have to wrap in promise
let result = await db.post({});
//This reads pretty nice?
let doc = await db.get(result.id);
console.log(doc);
} catch (err) {
console.log(err);
}
ES7 : ASYNC & AWAIT EXAMPLE 2
@boyney123
FURTHER READING
@boyney123
FURTHER READING
https://github.com/lukehoban/es6features
http://www.smashingmagazine.com/2015/10/es6-whats-new-next-version-javascript/
https://github.com/nzakas/understandinges6/tree/master/manuscript
https://github.com/bevacqua/es6
@boyney123
THANKS

More Related Content

What's hot (20)

JavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 
Javascript essentials
Javascript essentials
Bedis ElAchèche
 
An introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
React js
React js
Oswald Campesato
 
React render props
React render props
Saikat Samanta
 
Asynchronous JavaScript Programming
Asynchronous JavaScript Programming
Haim Michael
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
Lets make a better react form
Lets make a better react form
Yao Nien Chung
 
Intro to React
Intro to React
Justin Reock
 
React js
React js
Rajesh Kolla
 
Understanding react hooks
Understanding react hooks
Samundra khatri
 
Workshop 21: React Router
Workshop 21: React Router
Visual Engineering
 
Oops concepts in php
Oops concepts in php
CPD INDIA
 
React state
React state
Ducat
 
React hooks
React hooks
Ramy ElBasyouni
 
JavaScript Tutorial
JavaScript Tutorial
Bui Kiet
 
Redux workshop
Redux workshop
Imran Sayed
 
React js
React js
Jai Santhosh
 
JavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 
An introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Asynchronous JavaScript Programming
Asynchronous JavaScript Programming
Haim Michael
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
Lets make a better react form
Lets make a better react form
Yao Nien Chung
 
Understanding react hooks
Understanding react hooks
Samundra khatri
 
Oops concepts in php
Oops concepts in php
CPD INDIA
 
React state
React state
Ducat
 
JavaScript Tutorial
JavaScript Tutorial
Bui Kiet
 

Viewers also liked (16)

ES6: The Awesome Parts
ES6: The Awesome Parts
Domenic Denicola
 
Web Developers are now Mobile Developers
Web Developers are now Mobile Developers
boyney123
 
Quo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynote
Christian Heilmann
 
What's New in ES6 for Web Devs
What's New in ES6 for Web Devs
Rami Sayar
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
Christian Heilmann
 
BabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UI
modernweb
 
Emacscript 6
Emacscript 6
René Olivo
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016
Manoj Kumar
 
Running BabelJS on Windows (Try ES6 on Windows)
Running BabelJS on Windows (Try ES6 on Windows)
Kobkrit Viriyayudhakorn
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)
Joseph Chiang
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
Solution4Future
 
An Overview of the React Ecosystem
An Overview of the React Ecosystem
FITC
 
ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
Effective ES6
Effective ES6
Teppei Sato
 
A call to JS Developers - Let’s stop trying to impress each other and start b...
A call to JS Developers - Let’s stop trying to impress each other and start b...
Christian Heilmann
 
Lecture 2: ES6 / ES2015 Slide
Lecture 2: ES6 / ES2015 Slide
Kobkrit Viriyayudhakorn
 
Web Developers are now Mobile Developers
Web Developers are now Mobile Developers
boyney123
 
Quo vadis, JavaScript? Devday.pl keynote
Quo vadis, JavaScript? Devday.pl keynote
Christian Heilmann
 
What's New in ES6 for Web Devs
What's New in ES6 for Web Devs
Rami Sayar
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
Christian Heilmann
 
BabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UI
modernweb
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016
Manoj Kumar
 
Running BabelJS on Windows (Try ES6 on Windows)
Running BabelJS on Windows (Try ES6 on Windows)
Kobkrit Viriyayudhakorn
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)
Joseph Chiang
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
Solution4Future
 
An Overview of the React Ecosystem
An Overview of the React Ecosystem
FITC
 
ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
A call to JS Developers - Let’s stop trying to impress each other and start b...
A call to JS Developers - Let’s stop trying to impress each other and start b...
Christian Heilmann
 
Ad

Similar to Introduction into ES6 JavaScript. (20)

ECMAScript 2015
ECMAScript 2015
Sebastian Pederiva
 
Javantura 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
 
The ES Library for JavaScript Developers
The ES Library for JavaScript Developers
Ganesh Bhosale
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
Sencha
 
ES6 detailed slides for presentation.pptx
ES6 detailed slides for presentation.pptx
AneesLarik1
 
Introduction to es6
Introduction to es6
NexThoughts Technologies
 
ES6 - JavaCro 2016
ES6 - JavaCro 2016
Nenad Pecanac
 
Javascript ES6
Javascript ES6
Huy Doan
 
React Basic and Advance || React Basic
React Basic and Advance || React Basic
rafaqathussainc077
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
Mohd Saeed
 
Modern JS with ES6
Modern JS with ES6
Rifatul Islam
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
Lukas Ruebbelke
 
Getting started with ES6
Getting started with ES6
Nitay Neeman
 
Es6 day1
Es6 day1
Abhishek Sharma
 
Internal workshop es6_2015
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
Nilesh Jayanandana
 
Fitc whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 
ES6: Features + Rails
ES6: Features + Rails
Santosh Wadghule
 
JavaScript in 2016
JavaScript in 2016
Codemotion
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
The ES Library for JavaScript Developers
The ES Library for JavaScript Developers
Ganesh Bhosale
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
Sencha
 
ES6 detailed slides for presentation.pptx
ES6 detailed slides for presentation.pptx
AneesLarik1
 
Javascript ES6
Javascript ES6
Huy Doan
 
React Basic and Advance || React Basic
React Basic and Advance || React Basic
rafaqathussainc077
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
Mohd Saeed
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
Lukas Ruebbelke
 
Getting started with ES6
Getting started with ES6
Nitay Neeman
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
Nilesh Jayanandana
 
Fitc whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 
JavaScript in 2016
JavaScript in 2016
Codemotion
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
Ad

Recently uploaded (20)

Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 

Introduction into ES6 JavaScript.