Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Whats New In EcmaScript 2015 / ES6
Search
Hans Kristian Flaatten
January 28, 2016
Technology
79
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Whats New In EcmaScript 2015 / ES6
Hans Kristian Flaatten
January 28, 2016
More Decks by Hans Kristian Flaatten
See All by Hans Kristian Flaatten
Continuous Deployment with Jenkins Pipelines
starefossen
0
65
Continuous Integrations with Jenkins
starefossen
0
74
Testing Node.js
starefossen
0
36
What is Node.js?
starefossen
0
48
LeftPad Not Found
starefossen
0
92
Experience with NoSQL at the Norwegian Trekking Asocciation
starefossen
0
57
Introduction to Geospatial Queries in MongoDB
starefossen
0
43
Åpen Tur- og Friluftsdata
starefossen
0
110
Reverse Engineering APIs from iOS and Android Apps
starefossen
0
72
Other Decks in Technology
See All in Technology
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
330
Kiro Crewをはじめよう
kizawa2020
1
160
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
継続的なAIコスト最適化
bgpat
1
340
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
120
USB PDを使ってスマホを労わりたい
raspython3
0
180
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
130
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
190
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
290
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
180
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
150
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
130
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
A designer walks into a library…
pauljervisheath
211
25k
Building Applications with DynamoDB
mza
96
7.2k
Faster Mobile Websites
deanohume
310
32k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
A Modern Web Designer's Workflow
chriscoyier
699
190k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Product Roadmaps are Hard
iamctodd
55
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Navigating Team Friction
lara
192
16k
Transcript
ECMAScript 6 Hans Kristian Flaatten 1 Bergen Linux User Group
Torsdag 28. januar 2016 Bergen Offentlige Bibliotek
ES6 Hans Kristian Flaatten 2 Bergen Linux User Group Torsdag
28. januar 2016 Bergen Offentlige Bibliotek
ECMAScript 2015 Hans Kristian Flaatten 3 Bergen Linux User Group
Torsdag 28. januar 2016 Bergen Offentlige Bibliotek
JavaScript ≠ ECMAScript 4
• arrows functions • classes • enhanced object literals •
template strings • destructuring • default + rest + spread • let + const • iterators + for..of • generators • unicode • modules • module loaders • map + set + weakmap + weakset • proxies • symbols • subclassable built-ins • promises • math + number + string + array + object APIs • binary and octal literals • reflect api • tail calls 5
Block Scopes 6 (function () { var food = 'Meow
Mix'; }()); console.log(food); // Reference Error
Block Scopes 7 { let food = 'Meow Mix'; }
console.log(food); // Reference Error
Arrow Functions 8 function Person(name) { this.name = name; }
Person.prototype.prefixName = function (arr) { return arr.map(function (character) { return this.name + character; // Cannot read property 'name' of undefined }); };
Arrow Functions 9 function Person(name) { this.name = name; }
Person.prototype.prefixName = function (arr) { var that = this; // Store the context of this return arr.map(function (character) { return that.name + character; }); };
Arrow Functions 10 function Person(name) { this.name = name; }
Person.prototype.prefixName = function (arr) { return arr.map(character => this.name + character); };
Arrow Functions 11 var arr = [1, 2, 3, 4,
5]; var squares = arr.map(function (x) { return x * x });
Arrow Functions 12 var arr = [1, 2, 3, 4,
5]; var squares = arr.map(x => x * x);
Template Strings 13 var name = 'Tiger'; var age =
10; console.log('My name is ' + name + ', I am ' + age + ' years');
Template Strings 14 let name = 'Tiger'; let age =
10; console.log(`My name is ${name} and I am ${age} years.`);
Multiline Template Strings 15 var text = ( 'cat\n' +
'dog\n' + 'nickelodeon' );
Multiline Template Strings 16 var text = [ 'cat', 'dog',
'nickelodeon' ].join('\n');
Multiline Template Strings 17 let text = `cat dog nickelodeon`;
Destructing Arrays 18 var arr = [1, 2, 3, 4];
var a = arr[0]; var b = arr[1]; var c = arr[2]; var d = arr[3];
Destructing Arrays 19 let [a, b, c, d] = [1,
2, 3, 4]; console.log(a); // 1 console.log(b); // 2
Destructing Arrays 20 var luke = { occupation: 'jedi', father:
'anakin' }; var occupation = luke.occupation; // 'jedi' var father = luke.father; // 'anakin'
Destructing Arrays 21 let luke = { occupation: 'jedi', father:
'anakin' }; let {occupation, father} = luke; console.log(occupation); // 'jedi' console.log(father); // 'anakin'
Default Function Parameters 22 function addTwoNumbers(x, y) { x =
x || 0; y = y || 0; return x + y; }
Default Function Parameters 23 function addTwoNumbers(x=0, y=0) { return x
+ y; } addTwoNumbers(2, 4); // 6 addTwoNumbers(2); // 2 addTwoNumbers(); // 0
Named Function Parameters 24 function drawES5Chart(options) { options = options
=== undefined ? {} : options; var size = options.size === undefined ? 'big' : options.size; var cords = options.cords === undefined ? { x: 0, y: 0 } : options.cords; var radius = options.radius === undefined ? 25 : options.radius; console.log(size, cords, radius); // now finally do some chart drawing } drawES5Chart({ cords: { x: 18, y: 30 }, radius: 30 });
Named Function Parameters 25 function drawES6Chart({ size: size = 'big',
cords: cords = { x: 0, y: 0 }, radius: radius = 25 } = {}) { console.log(size, cords, radius); // do some chart drawing } drawES6Chart({ cords: { x: 18, y: 30 }, radius: 30 }); // 'big' {x: 18, y: 30} 30
Generators 26 function* fibonacci(){ let val1 = 0, val2 =
1, swap; yield val1; yield val2; while (true){ swap = val1 + val2; val1 = val2; val2 = swap; yield swap; } }
Generators 27 var sequence = fibonacci(); sequence.next().value // 0 sequence.next().value
// 1 sequence.next().value // 1 sequence.next().value // 2 sequence.next().value // 3 sequence.next().value // 5 sequence.next().value // 8
Browser Support 28 Browser ECMAScript 6 Support Google Chrome 91
% Edge 83 % FireFox 85 % Safari 54 % Kilde: https://kangax.github.io/compat-table/es6/
Node.js ES6 Support 29 0 25 50 75 100 v0.10
(3.14) v0.12 (v8 3.28) v4 (v8 4.5) v5 (v8 4.6) v6 (v8 5.0)
30
ECMAScript 7 ?! 31
ECMAScript 7 32
ECMAScript 2016 33