SlideShare a Scribd company logo
ES6ES8, ES 2017, ECMAScript
What is
ECMAScript?
ECMAScript is a standard.
JavaScript is the
implementation of ES standard.
1997 1998 1999 2009 2015 2016 2017
ES1 ES2 ES3 ES8 ESNextES5 ES6 ES7
ES2015 ES2016 ES2017
ES6
Variable Declaration
Object Literals
Arrow Functions
Assignment 

Destructuring
Rest and

Spread Operator
Template

Literals
async/await
Class
VARIABLE
DECLARATION
let — var with different scope rules.
{{{{{ var deep = 'This is available from outer scope.';}}}}}
console.log(deep);
!// This is available from outer scope.
ES5
{{{{{ let deep = 'This is available from outer scope.';}}}}}
console.log(deep);
!// ReferenceError: deep is not defined.
ES6
for (let i = 0; i < 2; i!++) {
console.log(i);
}
console.log(i);
!// 0, 1
!// ReferenceError: i is not defined
ES6
for (var i = 0; i < 2; i!++) {
console.log(i);
}
console.log(i);
!// 0, 1
!// 2
ES5
const — assignment only at declaration time.
const pi = 3.1415;
pi = 6;!// TypeError: Assignment to constant variable
ES6
OBJECT
LITERALS
Object Literal — key-value, powerful
data structure.
const book = {
title: 'Start With Why',
author: 'Simon Sinek',
publisher: 'Amazon'
};
let listeners = [];
function listen() {}
const podcast = {
listeners: listeners,
listen: listen
};
ES5
let listeners = [];
function listen() {}
const podcast = {
listeners,
listen
};
ES6
let emitter = {
events: {},
on: function(type, fn) {
if (this.events[type] !!=== undefined) {
this.events[type] = [];
}
this.events[type].push(fn);
},
emit: function(type, event) {
if (this.events[type] !!=== undefined) {
return;
}
this.events[type].forEach(function(fn) {
fn(event);
});
}
};
ES5
let emitter = {
events: {},
on(type, fn) {
if (this.events[type] !!=== undefined) {
this.events[type] = [];
}
this.events[type].push(fn);
},
emit(type, event) {
if (this.events[type] !!=== undefined) {
return;
}
this.events[type].forEach(function(fn) {
fn(event);
});
}
};
ES6
ARROW
FUNCTIONS
Arrow functions — another way of writing anonymous
functions.
function name(params) {
!// function body
}
ES5
const name = function (params) {
!// function body
}
ES5
const name = (params) => {
!// function body
}
ES6
Arrow functions — bound to their lexical scope, which is
the reason why they don’t alter the meaning of this.
const box = document.querySelector('.box');
box.addEventListener('click', () => {
console.log(this); !// window
});
ES6
const box = document.querySelector('.box');
box.addEventListener('click', function() {
console.log(this); !// <div class="box" …>
});
ES5
const box = document.querySelector('.box');
box.addEventListener('click', function() {
setTimeout(function() {
console.log(this); !// window
}, 1000);
});
ES5
const box = document.querySelector('.box');
box.addEventListener('click', function() {
window.setTimeout(function() {
console.log(this); !// window
}, 1000);
});
ES5
const box = document.querySelector('.box');
box.addEventListener('click', function() {
const that = this;
window.setTimeout(function() {
console.log(that); !// <div class="box" …>
}, 1000);
});
ES5
const box = document.querySelector('.box');
box.addEventListener('click', function() {
window.setTimeout(() => {
console.log(this); !// <div class="box" …>
}, 1000);
});
ES6ES5
ASSIGNMENT
DESTRUCTURING
Destructuring — Binds properties to as many variables as
you need. It works with objects, arrays, and even in
function parameter lists.
const character = {
name: 'Bruce',
pseudonym: 'Batman',
metadata: {
age: 34,
gender: 'male',
},
superpower: ['rich', 'sugardaddy'],
};
const pseudonym = character.pseudonym;
const name = character.name;
const superpower = character.superpower;
ES5
const character = {
name: 'Bruce',
pseudonym: 'Batman',
metadata: {
age: 34,
gender: 'male'
},
superpower: ['rich', 'sugardaddy']
};
const { pseudonym, name, superpower } = character;
ES6
const character = {
name: 'Bruce',
pseudonym: 'Batman',
metadata: {
age: 34,
gender: 'male'
},
superpower: ['rich', 'sugardaddy']
};
const { pseudonym: alias } = character;
ES6
const character = {
name: 'Bruce',
pseudonym: 'Batman',
metadata: {
age: 34,
gender: 'male',
},
superpower: ['rich', 'sugardaddy'],
};
const { pseudonym: alias } = character.pseudonym;
console.log(alias); !// Batman
const { metadata: { gender: charGender } } = character;
console.log(charGender); !// male
ES6
const coordinate = [7.7956, 110.3695];
const [lat, lng] = coordinates;
ES6
const data = 'Lego City,toys,90290,2';
const [itemName, category, sku, qty] = data.split(',');
console.log(itemName, category, sku, qty);
ES6
…
Rest parameter — Better interaction with an arbitrary
amount of function parameters.
ES5
function convertCurrency() {
console.log(arguments); !// [1.1, 1, 10, 20]
const rate = arguments[0];
let amounts = [];
for (let i = 1; i < arguments.length; i!++) {
amounts.push(arguments[i]);
}
return amounts.map((amount) !=> amount * rate);
}
console.log(convertCurrency(1.1, 1, 10, 20));
!// [ 1.1, 11, 22 ]
function convertCurrency() {
console.log(arguments); !// [1.1, 1, 10, 20]
const rate = arguments[0];
let amounts = [];
for (let i = 1; i < arguments.length; i!++) {
amounts.push(arguments[i]);
}
return amounts.map((amount) !=> amount * rate);
}
console.log(convertCurrency(1.1, 1, 10, 20));
!// [ 1.1, 11, 22 ]
ES5
function convertCurrency(rate, !!...amounts) {
return amounts.map((amount) !=> amount * rate);
}
console.log(convertCurrency(1.1, 1, 10, 20));
!// [ 1.1, 11, 22 ]
ES6
const runner = ['Mario', 'id123', 4.3, 4.1, 3.6, 1.9, 6.0];
const [name, id, !!...runs] = runner;
console.log(name, id, runs);
!// Mario id123 [ 4.3, 4.1, 3.6, 1.9, 6 ]
ES6
Spread operator — cast any iterable object into an array.
const foods = ['Gudeg', 'Krecek'];
const souvenirs = ['Wayang', 'Batik'];
let shopping = [];
shopping = shopping.concat(foods);
shopping.push('Bakpia');
shopping = shopping.concat(souvenirs);
console.log(shopping);
!// [ 'Gudeg', 'Krecek', 'Bakpia', 'Wayang', 'Batik' ]
ES5
const foods = ['Gudeg', 'Krecek'];
const souvenirs = ['Wayang', 'Batik'];
let shopping = [!!...foods, 'Bakpia', !!...souvenirs];
shopping = ['Bakpia', !!...foods, !!...souvenirs];
shopping = [!!...foods, !!...souvenirs, 'Bakpia'];
ES6
TEMPLATE
LITERALS
Template literals — Vast improvement upon regular
JavaScript strings.
const name = 'Lucy';
const age = 6;
const sentence = 'My guitar ' + name + ' is ' +
age * 2 + ' years old.';
console.log(sentence);
ES5
const name = 'Lucy';
const age = 6;
const sentence = `My guitar ${name} is ${age *
2} years old.`;
console.log(sentence);
ES6
const escaped = 'The first line
A second line
Then a third line.';
ES5
const escaped = `The first line
A second line
Then a third line.`;
ES6
const name = 'Lucy';
const age = 6;
let markup = '<div><h2>Guitar: ' + name + '!</h2>';
markup += '<span class="age">' + age + ' years
old.!</span>!</div>';
ES5
const name = 'Lucy';
const age = 6;
let markup = `
<div>
<h2>Guitar: ${name}!</h2>
<span class="age">${age} years old.!</span>
!</div>`;
ES6
const Button = styled.a`
display: inline-block;
border-radius: 3px;
padding: 0.5rem 0;
margin: 0.5rem 1rem;
width: 11rem;
background: transparent;
color: white;
border: 2px solid white;
${(props) !=>
props.primary !&&
css`
background: white;
color: palevioletred;
`};
`;
ES6
export const pageQuery = graphql`
query {
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) {
edges {
node {
id
excerpt(pruneLength: 250)
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
title
}
}
}
}
}
`;
ES6
CLASS
Classes — Provide syntax to represent prototypal inheritance
under the traditional class-based programming paradigm.
function Fruit(name, calories) {
this.name = name;
this.calories = calories;
this.pieces = 1;
}
Fruit.prototype.chop = function() {
this.pieces!++;
}
Fruit.prototype.bite = function(person) {
if (this.pieces < 1) {
return;
}
const calories = this.calories / this.pieces;
person.satiety += calories;
this.calories -= calories;
this.pieces!--;
}
ES5
const person = { satiety: 0 };
const apple = new Fruit('apple', 140);
apple.chop();
apple.chop();
apple.chop();
apple.bite(person);
apple.bite(person);
apple.bite(person);
console.log(person.satiety); !// 105
console.log(apple.pieces); !// 1
console.log(apple.calories); !// 35
ES5
class Fruit {
constructor(name, calories) {
this.name = name;
this.calories = calories;
this.pieces = 1;
}
chop() {
this.pieces!++;
}
bite(person) {
if (this.pieces < 1) {
return;
}
const calories = this.calories / this.pieces;
person.satiety += calories;
this.calories -= calories;
this.pieces!--;
}
}
ES6
function Banana() {
Fruit.call(this, 'banana', 105);
}
Banana.prototype = Object.create(Fruit.prototype);
Banana.prototype.slice = function() {
this.pieces = 12;
};
ES5
ES6
class Banana extends Fruit {
constructor() {
super('banana', 105);
}
slice() {
this.pieces = 12;
}
}
ASYNC/AWAIT
async/await — Syntactic sugar for promise-based
implementation and take advantage of the synchronous
style of code.
getProfile("rizafahmi")
.then(profile !=> getRepos(profile.login))
.then(repos !=> countTotalStars(repos))
.catch(err !=> {
console.error(err);
});
const countStars = async () !=> {
const profile = await getProfile("rizafahmi");
const repos = await getRepos(riza_profile.login);
const stars = countTotalStars(riza_repos);
};
countStars();
(async () !=> {
const profile = await getProfile("rizafahmi");
const repos = await getRepos(riza_profile.login);
const stars = countTotalStars(riza_repos);
})();
“Talk is cheap show me the code” — Linus Torvalds
github.com/rizafahmi/github-profiler-cli
slideshare.net/rizafahmi
twitter.com/rizafahmi22
facebook.com/rizafahmi
riza@hacktiv8.com
ceritanyadeveloper.com

More Related Content

What's hot

Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
Ingvar Stepanyan
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Bongwon Lee
 
스위프트를 여행하는 히치하이커를 위한 스타일 안내
스위프트를 여행하는 히치하이커를 위한 스타일 안내스위프트를 여행하는 히치하이커를 위한 스타일 안내
스위프트를 여행하는 히치하이커를 위한 스타일 안내
Jung Kim
 
Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
Aaron Huang
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
Rafael Dohms
 
PHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPositive Hack Days
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Mail.ru Group
 
Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHP
Guilherme Blanco
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
Ingvar Stepanyan
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
Rafael Dohms
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8
Wilson Su
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
Guilherme Blanco
 
PHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Dam
 
Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8
Wilson Su
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
James Titcumb
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
Sanketkumar Biswas
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
Masahiro Honma
 
Practical JavaScript Programming - Session 7/8
Practical JavaScript Programming - Session 7/8Practical JavaScript Programming - Session 7/8
Practical JavaScript Programming - Session 7/8
Wilson Su
 

What's hot (18)

Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
 
스위프트를 여행하는 히치하이커를 위한 스타일 안내
스위프트를 여행하는 히치하이커를 위한 스타일 안내스위프트를 여행하는 히치하이커를 위한 스타일 안내
스위프트를 여행하는 히치하이커를 위한 스타일 안내
 
Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
PHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an AnalysisPHP Object Injection Vulnerability in WordPress: an Analysis
PHP Object Injection Vulnerability in WordPress: an Analysis
 
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
Security Meetup 22 октября. «Реверс-инжиниринг в Enterprise». Алексей Секрето...
 
Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHP
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 
PHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
 
Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Practical JavaScript Programming - Session 7/8
Practical JavaScript Programming - Session 7/8Practical JavaScript Programming - Session 7/8
Practical JavaScript Programming - Session 7/8
 

Similar to Essentials and Impactful Features of ES6

Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
Justin Alexander
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015qmmr
 
Adding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
Jeff Strauss
 
ES6: The future is now
ES6: The future is nowES6: The future is now
ES6: The future is now
Sebastiano Armeli
 
Ecmascript 6
Ecmascript 6Ecmascript 6
Ecmascript 6
Gatuk S. Chattanon
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
Santosh Wadghule
 
"let ECMAScript = 6"
"let ECMAScript = 6" "let ECMAScript = 6"
"let ECMAScript = 6"
The Software House
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
Krzysztof Szafranek
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
James Ford
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
Lukas Ruebbelke
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
JavaScript Futures—ES2017 and Beyond
JavaScript Futures—ES2017 and BeyondJavaScript Futures—ES2017 and Beyond
JavaScript Futures—ES2017 and Beyond
Jeff Strauss
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
Visual Engineering
 
ES6 and AngularAMD
ES6 and AngularAMDES6 and AngularAMD
ES6 and AngularAMD
dhaval10690
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
Domenic Denicola
 
What's New in JavaScript
What's New in JavaScriptWhat's New in JavaScript
What's New in JavaScript
Dan Cohn
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
Luis Vendrame
 
Javascript
JavascriptJavascript
Javascript
Vlad Ifrim
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
Rick Beerendonk
 

Similar to Essentials and Impactful Features of ES6 (20)

Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
Adding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
 
ES6: The future is now
ES6: The future is nowES6: The future is now
ES6: The future is now
 
Ecmascript 6
Ecmascript 6Ecmascript 6
Ecmascript 6
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
"let ECMAScript = 6"
"let ECMAScript = 6" "let ECMAScript = 6"
"let ECMAScript = 6"
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
JavaScript Futures—ES2017 and Beyond
JavaScript Futures—ES2017 and BeyondJavaScript Futures—ES2017 and Beyond
JavaScript Futures—ES2017 and Beyond
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
ES6 and AngularAMD
ES6 and AngularAMDES6 and AngularAMD
ES6 and AngularAMD
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
What's New in JavaScript
What's New in JavaScriptWhat's New in JavaScript
What's New in JavaScript
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 

More from Riza Fahmi

Membangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan PhoenixMembangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan Phoenix
Riza Fahmi
 
Berbagai Pilihan Karir Developer
Berbagai Pilihan Karir DeveloperBerbagai Pilihan Karir Developer
Berbagai Pilihan Karir Developer
Riza Fahmi
 
Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020
Riza Fahmi
 
Remote Working/Learning
Remote Working/LearningRemote Working/Learning
Remote Working/Learning
Riza Fahmi
 
How to learn programming
How to learn programmingHow to learn programming
How to learn programming
Riza Fahmi
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS Amplify
Riza Fahmi
 
Menguak Misteri Module Bundler
Menguak Misteri Module BundlerMenguak Misteri Module Bundler
Menguak Misteri Module Bundler
Riza Fahmi
 
Beberapa Web API Menarik
Beberapa Web API MenarikBeberapa Web API Menarik
Beberapa Web API Menarik
Riza Fahmi
 
MVP development from software developer perspective
MVP development from software developer perspectiveMVP development from software developer perspective
MVP development from software developer perspective
Riza Fahmi
 
Ekosistem JavaScript di Indonesia
Ekosistem JavaScript di IndonesiaEkosistem JavaScript di Indonesia
Ekosistem JavaScript di Indonesia
Riza Fahmi
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonML
Riza Fahmi
 
How I Generate Idea
How I Generate IdeaHow I Generate Idea
How I Generate Idea
Riza Fahmi
 
Strategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop SlideStrategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop Slide
Riza Fahmi
 
Lesson Learned from Prolific Developers
Lesson Learned from Prolific DevelopersLesson Learned from Prolific Developers
Lesson Learned from Prolific Developers
Riza Fahmi
 
Clean Code JavaScript
Clean Code JavaScriptClean Code JavaScript
Clean Code JavaScript
Riza Fahmi
 
The Future of AI
The Future of AIThe Future of AI
The Future of AI
Riza Fahmi
 
Chrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take AwaysChrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take Aways
Riza Fahmi
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
Riza Fahmi
 
Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonML
Riza Fahmi
 
Machine learning with py torch
Machine learning with py torchMachine learning with py torch
Machine learning with py torch
Riza Fahmi
 

More from Riza Fahmi (20)

Membangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan PhoenixMembangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan Phoenix
 
Berbagai Pilihan Karir Developer
Berbagai Pilihan Karir DeveloperBerbagai Pilihan Karir Developer
Berbagai Pilihan Karir Developer
 
Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020
 
Remote Working/Learning
Remote Working/LearningRemote Working/Learning
Remote Working/Learning
 
How to learn programming
How to learn programmingHow to learn programming
How to learn programming
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS Amplify
 
Menguak Misteri Module Bundler
Menguak Misteri Module BundlerMenguak Misteri Module Bundler
Menguak Misteri Module Bundler
 
Beberapa Web API Menarik
Beberapa Web API MenarikBeberapa Web API Menarik
Beberapa Web API Menarik
 
MVP development from software developer perspective
MVP development from software developer perspectiveMVP development from software developer perspective
MVP development from software developer perspective
 
Ekosistem JavaScript di Indonesia
Ekosistem JavaScript di IndonesiaEkosistem JavaScript di Indonesia
Ekosistem JavaScript di Indonesia
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonML
 
How I Generate Idea
How I Generate IdeaHow I Generate Idea
How I Generate Idea
 
Strategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop SlideStrategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop Slide
 
Lesson Learned from Prolific Developers
Lesson Learned from Prolific DevelopersLesson Learned from Prolific Developers
Lesson Learned from Prolific Developers
 
Clean Code JavaScript
Clean Code JavaScriptClean Code JavaScript
Clean Code JavaScript
 
The Future of AI
The Future of AIThe Future of AI
The Future of AI
 
Chrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take AwaysChrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take Aways
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
 
Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonML
 
Machine learning with py torch
Machine learning with py torchMachine learning with py torch
Machine learning with py torch
 

Recently uploaded

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Essentials and Impactful Features of ES6

  • 1. ES6ES8, ES 2017, ECMAScript
  • 3. ECMAScript is a standard.
  • 5. 1997 1998 1999 2009 2015 2016 2017 ES1 ES2 ES3 ES8 ESNextES5 ES6 ES7 ES2015 ES2016 ES2017
  • 6. ES6 Variable Declaration Object Literals Arrow Functions Assignment 
 Destructuring Rest and
 Spread Operator Template
 Literals async/await Class
  • 8. let — var with different scope rules.
  • 9. {{{{{ var deep = 'This is available from outer scope.';}}}}} console.log(deep); !// This is available from outer scope. ES5
  • 10. {{{{{ let deep = 'This is available from outer scope.';}}}}} console.log(deep); !// ReferenceError: deep is not defined. ES6
  • 11. for (let i = 0; i < 2; i!++) { console.log(i); } console.log(i); !// 0, 1 !// ReferenceError: i is not defined ES6
  • 12. for (var i = 0; i < 2; i!++) { console.log(i); } console.log(i); !// 0, 1 !// 2 ES5
  • 13. const — assignment only at declaration time.
  • 14. const pi = 3.1415; pi = 6;!// TypeError: Assignment to constant variable ES6
  • 16. Object Literal — key-value, powerful data structure.
  • 17. const book = { title: 'Start With Why', author: 'Simon Sinek', publisher: 'Amazon' };
  • 18. let listeners = []; function listen() {} const podcast = { listeners: listeners, listen: listen }; ES5
  • 19. let listeners = []; function listen() {} const podcast = { listeners, listen }; ES6
  • 20. let emitter = { events: {}, on: function(type, fn) { if (this.events[type] !!=== undefined) { this.events[type] = []; } this.events[type].push(fn); }, emit: function(type, event) { if (this.events[type] !!=== undefined) { return; } this.events[type].forEach(function(fn) { fn(event); }); } }; ES5
  • 21. let emitter = { events: {}, on(type, fn) { if (this.events[type] !!=== undefined) { this.events[type] = []; } this.events[type].push(fn); }, emit(type, event) { if (this.events[type] !!=== undefined) { return; } this.events[type].forEach(function(fn) { fn(event); }); } }; ES6
  • 23. Arrow functions — another way of writing anonymous functions.
  • 24. function name(params) { !// function body } ES5
  • 25. const name = function (params) { !// function body } ES5
  • 26. const name = (params) => { !// function body } ES6
  • 27. Arrow functions — bound to their lexical scope, which is the reason why they don’t alter the meaning of this.
  • 28. const box = document.querySelector('.box'); box.addEventListener('click', () => { console.log(this); !// window }); ES6
  • 29. const box = document.querySelector('.box'); box.addEventListener('click', function() { console.log(this); !// <div class="box" …> }); ES5
  • 30. const box = document.querySelector('.box'); box.addEventListener('click', function() { setTimeout(function() { console.log(this); !// window }, 1000); }); ES5
  • 31. const box = document.querySelector('.box'); box.addEventListener('click', function() { window.setTimeout(function() { console.log(this); !// window }, 1000); }); ES5
  • 32. const box = document.querySelector('.box'); box.addEventListener('click', function() { const that = this; window.setTimeout(function() { console.log(that); !// <div class="box" …> }, 1000); }); ES5
  • 33. const box = document.querySelector('.box'); box.addEventListener('click', function() { window.setTimeout(() => { console.log(this); !// <div class="box" …> }, 1000); }); ES6ES5
  • 35. Destructuring — Binds properties to as many variables as you need. It works with objects, arrays, and even in function parameter lists.
  • 36. const character = { name: 'Bruce', pseudonym: 'Batman', metadata: { age: 34, gender: 'male', }, superpower: ['rich', 'sugardaddy'], }; const pseudonym = character.pseudonym; const name = character.name; const superpower = character.superpower; ES5
  • 37. const character = { name: 'Bruce', pseudonym: 'Batman', metadata: { age: 34, gender: 'male' }, superpower: ['rich', 'sugardaddy'] }; const { pseudonym, name, superpower } = character; ES6
  • 38. const character = { name: 'Bruce', pseudonym: 'Batman', metadata: { age: 34, gender: 'male' }, superpower: ['rich', 'sugardaddy'] }; const { pseudonym: alias } = character; ES6
  • 39. const character = { name: 'Bruce', pseudonym: 'Batman', metadata: { age: 34, gender: 'male', }, superpower: ['rich', 'sugardaddy'], }; const { pseudonym: alias } = character.pseudonym; console.log(alias); !// Batman const { metadata: { gender: charGender } } = character; console.log(charGender); !// male ES6
  • 40. const coordinate = [7.7956, 110.3695]; const [lat, lng] = coordinates; ES6
  • 41. const data = 'Lego City,toys,90290,2'; const [itemName, category, sku, qty] = data.split(','); console.log(itemName, category, sku, qty); ES6
  • 42.
  • 43. Rest parameter — Better interaction with an arbitrary amount of function parameters.
  • 44. ES5 function convertCurrency() { console.log(arguments); !// [1.1, 1, 10, 20] const rate = arguments[0]; let amounts = []; for (let i = 1; i < arguments.length; i!++) { amounts.push(arguments[i]); } return amounts.map((amount) !=> amount * rate); } console.log(convertCurrency(1.1, 1, 10, 20)); !// [ 1.1, 11, 22 ]
  • 45. function convertCurrency() { console.log(arguments); !// [1.1, 1, 10, 20] const rate = arguments[0]; let amounts = []; for (let i = 1; i < arguments.length; i!++) { amounts.push(arguments[i]); } return amounts.map((amount) !=> amount * rate); } console.log(convertCurrency(1.1, 1, 10, 20)); !// [ 1.1, 11, 22 ] ES5
  • 46. function convertCurrency(rate, !!...amounts) { return amounts.map((amount) !=> amount * rate); } console.log(convertCurrency(1.1, 1, 10, 20)); !// [ 1.1, 11, 22 ] ES6
  • 47. const runner = ['Mario', 'id123', 4.3, 4.1, 3.6, 1.9, 6.0]; const [name, id, !!...runs] = runner; console.log(name, id, runs); !// Mario id123 [ 4.3, 4.1, 3.6, 1.9, 6 ] ES6
  • 48. Spread operator — cast any iterable object into an array.
  • 49. const foods = ['Gudeg', 'Krecek']; const souvenirs = ['Wayang', 'Batik']; let shopping = []; shopping = shopping.concat(foods); shopping.push('Bakpia'); shopping = shopping.concat(souvenirs); console.log(shopping); !// [ 'Gudeg', 'Krecek', 'Bakpia', 'Wayang', 'Batik' ] ES5
  • 50. const foods = ['Gudeg', 'Krecek']; const souvenirs = ['Wayang', 'Batik']; let shopping = [!!...foods, 'Bakpia', !!...souvenirs]; shopping = ['Bakpia', !!...foods, !!...souvenirs]; shopping = [!!...foods, !!...souvenirs, 'Bakpia']; ES6
  • 52. Template literals — Vast improvement upon regular JavaScript strings.
  • 53. const name = 'Lucy'; const age = 6; const sentence = 'My guitar ' + name + ' is ' + age * 2 + ' years old.'; console.log(sentence); ES5
  • 54. const name = 'Lucy'; const age = 6; const sentence = `My guitar ${name} is ${age * 2} years old.`; console.log(sentence); ES6
  • 55. const escaped = 'The first line A second line Then a third line.'; ES5
  • 56. const escaped = `The first line A second line Then a third line.`; ES6
  • 57. const name = 'Lucy'; const age = 6; let markup = '<div><h2>Guitar: ' + name + '!</h2>'; markup += '<span class="age">' + age + ' years old.!</span>!</div>'; ES5
  • 58. const name = 'Lucy'; const age = 6; let markup = ` <div> <h2>Guitar: ${name}!</h2> <span class="age">${age} years old.!</span> !</div>`; ES6
  • 59. const Button = styled.a` display: inline-block; border-radius: 3px; padding: 0.5rem 0; margin: 0.5rem 1rem; width: 11rem; background: transparent; color: white; border: 2px solid white; ${(props) !=> props.primary !&& css` background: white; color: palevioletred; `}; `; ES6
  • 60. export const pageQuery = graphql` query { allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) { edges { node { id excerpt(pruneLength: 250) frontmatter { date(formatString: "MMMM DD, YYYY") path title } } } } } `; ES6
  • 61. CLASS
  • 62. Classes — Provide syntax to represent prototypal inheritance under the traditional class-based programming paradigm.
  • 63. function Fruit(name, calories) { this.name = name; this.calories = calories; this.pieces = 1; } Fruit.prototype.chop = function() { this.pieces!++; } Fruit.prototype.bite = function(person) { if (this.pieces < 1) { return; } const calories = this.calories / this.pieces; person.satiety += calories; this.calories -= calories; this.pieces!--; } ES5
  • 64. const person = { satiety: 0 }; const apple = new Fruit('apple', 140); apple.chop(); apple.chop(); apple.chop(); apple.bite(person); apple.bite(person); apple.bite(person); console.log(person.satiety); !// 105 console.log(apple.pieces); !// 1 console.log(apple.calories); !// 35 ES5
  • 65. class Fruit { constructor(name, calories) { this.name = name; this.calories = calories; this.pieces = 1; } chop() { this.pieces!++; } bite(person) { if (this.pieces < 1) { return; } const calories = this.calories / this.pieces; person.satiety += calories; this.calories -= calories; this.pieces!--; } } ES6
  • 66. function Banana() { Fruit.call(this, 'banana', 105); } Banana.prototype = Object.create(Fruit.prototype); Banana.prototype.slice = function() { this.pieces = 12; }; ES5
  • 67. ES6 class Banana extends Fruit { constructor() { super('banana', 105); } slice() { this.pieces = 12; } }
  • 69. async/await — Syntactic sugar for promise-based implementation and take advantage of the synchronous style of code.
  • 70. getProfile("rizafahmi") .then(profile !=> getRepos(profile.login)) .then(repos !=> countTotalStars(repos)) .catch(err !=> { console.error(err); });
  • 71. const countStars = async () !=> { const profile = await getProfile("rizafahmi"); const repos = await getRepos(riza_profile.login); const stars = countTotalStars(riza_repos); }; countStars();
  • 72. (async () !=> { const profile = await getProfile("rizafahmi"); const repos = await getRepos(riza_profile.login); const stars = countTotalStars(riza_repos); })();
  • 73. “Talk is cheap show me the code” — Linus Torvalds