Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tomorrow's Javascript, Today.
Search
Jason L Perry
March 02, 2016
Programming
0
92
Tomorrow's Javascript, Today.
A Crash Course in ES2015 and ES2016 JavaScript given at The Iron Yard.
Jason L Perry
March 02, 2016
Tweet
Share
More Decks by Jason L Perry
See All by Jason L Perry
Advanced JS Crash Course
ambethia
1
370
Intro to Javascript
ambethia
1
100
Ruby for the Newbie
ambethia
2
120
A naïve introduction to mruby
ambethia
3
800
Other Decks in Programming
See All in Programming
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
3
1.1k
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.6k
SpringBoot3.4の構造化ログ #kanjava
irof
2
880
個人アプリを2年ぶりにアプデしたから褒めて / I just updated my personal app, praise me!
lovee
0
320
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
110
令和7年版 あなたが使ってよいフロントエンド機能とは
mugi_uno
12
6.1k
Linux && Docker 研修/Linux && Docker training
forrep
23
4.3k
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
190
技術を根付かせる / How to make technology take root
kubode
1
110
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
190
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
20
3.4k
CloudNativePGがCNCF Sandboxプロジェクトになったぞ! 〜CloudNativePGの仕組みの紹介〜
nnaka2992
0
210
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.4k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Music & Morning Musume
bryan
46
6.3k
Into the Great Unknown - MozCon
thekraken
34
1.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Statistics for Hackers
jakevdp
797
220k
Practical Orchestrator
shlominoach
186
10k
Writing Fast Ruby
sferik
628
61k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Transcript
1
Tomorrow's JavaScript, Today. 2
Audience 3
What is "ECMAScript?" 4
Ecma International 5
6
Other implementations and dialects 4 ActionScript 4 UnityScript 4 JerryScript
7
Features 8
let & const Forget var. 9
(function() { for (var i = 0; i < 2;
i++) { // ... } console.log(i); })(); // > 2 10
(function() { for (let i = 0; i < 2;
i++) { // ... } console.log(i); })(); // ! Uncaught ReferenceError: i is not defined 11
const PHI = 1.618; 12
13
Assignment Destructuring 14
var numbers = [42, Math.PI * 2]; var life =
numbers[0]; var tau = numbers[1]; 15
const [life, ταυ] = [42, Math.PI * 2]; // life
=== 42 // ταυ === 6.283185 16
const numbers = { life: 42, ταυ: Math.PI * 2
}; let { life, ταυ } = numbers; // life === 42 // ταυ === 6.283185 17
18
const numbers = { life: 42, ταυ: Math.PI * 2
}; let { universe, τ } = numbers; // universe === 42 // τ === 6.283185 19
Template Literals 20
'single' "double" `backticks` 21
String Interpolation 22
const q = 'questions'; const a = 'answers'; let s
= `Sometimes the ${q} are complicated and the ${a} are simple.`; 23
24
var q = 'questions'; var a = 'answers'; var s
= 'Sometimes the ' + q + ' are complicated and the ' + a + ' are simple.'; 25
26
Multiline Strings 27
const l = `Unless someone like you cares a whole
awful lot, Nothing is going to get better. It's not.` 28
var l = 'Unless someone like you cares a whole
awful lot,\n Nothing is going to get better.\n It\'s not.'; 29
var l = 'Unless someone like you cares a whole
awful lot,\n' + ' Nothing is going to get better.\n' + " It's not."; 30
31
Spread Operator (...) 32
let colors = ['Red', 'Blue']; let words = ['One', 'Two',
...colors]; 33
function fish() { for (var i = 0; i <
arguments.length; i++) { console.log(arguments[i], 'fish.'); } } fish(...words); // > One fish. // > Two fish. // > Red fish. // > Blue fish. 34
35
fish.apply(null, words); 36
37
Arrow Functions 38
const numbers = [42, 665]; numbers.map((n) => { return n
* ταυ; }); 39
numbers.map((n) => return n * ταυ); 40
function fish(words) { this.subject = 'fish.'; words.forEach(function (word) { console.log(word,
this.subject); }.bind(this)); } 41
function fish(words) { this.subject = 'fish.'; words.forEach((word) => console.log(word, this.subject));
} 42
43
Default Parameter Values 44
function increase(number, increment) { increment = increment || 1; return
number + increment; } increase(41, 624); // 665 increase(41); // 42 45
function increase(number, increment = 1) { return number + increment;
} increase(41, 624); // 665 increase(41); // 42 46
Rest Parameters (...) 47
const feed = (monster, ...numnums) { nomnoms.forEach((nom) => monster.eat(nom)); };
48
function feed(monster) { var nomnoms = Array.prototype.slice.call(arguments, feed.length); nomnoms.forEach(function (nom)
{ monster.eat(nom); }); }; 49
New String APIs 50
Including, but not limited to: 4 String.prototype.startsWith() 4 String.prototype.endsWith() 4
String.prototype.contains() 4 String.prototype.repeat() 4 String.prototype.normalize() 51
New Array APIs 52
Including, but not limited to: 4 Array.prototype.find() 4 Array.prototype.findIndex() 4
Array.prototype.fill() 4 Array.prototype.includes() (ES2016) 53
Array.from() 54
let inputs = document.querySelectorAll('form input'); for (var i = 0;
i < inputs.length; i++) { inputs[i].disable = true; } 55
let inputs = document.querySelectorAll('form input'); Array.from(inputs).forEach((el) => el.disable = true);
56
57
Array.of() 58
let data = [42, 665]; let copy = new Array(...data);
copy // [42, 665] 59
let data = 42; let copy = new Array(...data); copy
// [] 60
61
let data = 42; let copy = Array.of(...data); copy //
[42] 62
Binary and Octal Literal Notation 63
console.log(0x10, 0x2A); // > 16 42 64
console.log(0b10, 0b101010); // > 2 42 console.log(0o10, 0o52); // >
8 42 65
Object Literals 66
let data = '.uǝɹpןıɥɔ ǝʇǝןosqo ǝɹɐ sʇןnpɐ'; let msg =
{ id: 42, data } { id: 42, data: '.uǝɹpןıɥɔ ǝʇǝןosqo ǝɹɐ sʇןnpɐ' } 67
let msg = { id: 42, data, read() { this.data.flip()
} } 68
Classes 69
class Member { constructor(givenName, familyName, rank = 1) { //
super() this.givenName = givenName; this.familyName = familyName; } promote() { this.rank++; } get displayName() { return `${this.givenName} ${this.familyName} (${'*'.repeat(rank)})`; } } let member = new Member('Jason', 'Perry'); member.promote(); console.log(member.displayName); // > "Jason Perry (**)" 70
Modules 71
import React from 'react'; const App = React.createClass({ propTypes: {
title: React.PropTypes.string }, // ... }); export default App; 72
import { Component, PropTypes } from 'react'; class App extends
Component { static propTypes = { title: PropTypes.string } // ... } class Menu extends Component { // ... } export { App, Menu }; import ReactDOM from 'react-dom'; import { App } from './components'; ReactDom.render(App, document.findElementById('root')); 73
Making Use of ES2015, in, er... 2016. 74
Current Browser Support 75
Transpilers 76
4 Babel 4 Traceur 4 TypeScript 4 CoffeeScript 4 JSX
Transformer 77
Babel 78
npm install -g babel-cli 79
babel index.js -o public/main.js 80
babel-node --presets es2015 app.js 81
Configuring Babel 6 82
{ "presets": ["es2015", "react", "stage-0"], "env": { "development": { "plugins":
[ ["react-transform", { "transforms": [{ "transform": "react-transform-hmr", "imports": ["react"], "locals": ["module"] }] }] ] } } } 83
84
What didn't we cover? 85
4 for...of iteration 4 Promise 4 Symbol 4 Map &
Set Collections 4 Comprehensions 4 Module loaders 4 Proxy & Reflection APIs 4 Subclassable Built-ins 4 async/await (ES2016) 4 Generators (ES2016) 4 Decorators (ES2016) 4 Better Unicode support 4 New Math & Number APIs 86
Resources 4 http://exploring js.com 4 https://babeljs.io/docs/learn-es2015/ 4 https://nodejs.org/en/docs/es6/ 4 http://kangax.github.io/compat-table
4 http://www.2ality.com/2015/04/numbers-math- es6.html 87
@ambethia 88
89