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
いまからはじめるECMAScript 6 / Begin ECMAScript6
Search
Shogo Sensui
June 13, 2015
Technology
0
860
いまからはじめるECMAScript 6 / Begin ECMAScript6
2015年6月13日に行われたHTML5オールスターズ勉強会の「いまからはじめるECMAScript 6」のセッションの資料です。
Shogo Sensui
June 13, 2015
Tweet
Share
More Decks by Shogo Sensui
See All by Shogo Sensui
EU のデジタル市場法と Apple / DMA and Apple
1000ch
0
72
Web Share API
1000ch
0
83
2023 年の Web 開発のベースライン / Web Development Baseline 2023
1000ch
0
27
開発生産性と組織 / Productivity and Organization
1000ch
0
1.1k
なぜ私達は働くのか / Why We Work?
1000ch
0
47
新しいメルカリ Web とそのパフォーマンス / The New Mercari Web and its performance
1000ch
0
43
Web Standards Interop 2022
1000ch
0
270
パフォーマンスを高める CSS / Performance Optimized CSS
1000ch
1
750
HTML Optimization for Web Performance
1000ch
0
680
Other Decks in Technology
See All in Technology
【shownet.conf_】革新と伝統を融合したファシリティ
shownet
PRO
0
310
Oracle Database 23ai 新機能#4 Application Continuity
oracle4engineer
PRO
0
110
VS CodeでF1〜12キーつかってますか? / Do you use the F1-12 keys in VS Code?
74th
2
290
小さな勉強会の始め方、広げ方、あるいは友達の作り方 / How to Start, Grow, and Build Connections with Small Study Groups
ar_tama
5
2.3k
【shownet.conf_】ローカル5Gを活用したウォーキングツアーの体感向上
shownet
PRO
0
320
ドメインと向き合う - 旅行予約編
hidenorigoto
4
550
XPを始める新人に伝えたい近道の鍵
nakasho
1
290
Causal Impactを用いたLINE Pay UIの効果検証とABテスト実施への貢献
lycorptech_jp
PRO
3
540
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
5
1.8k
ADRを運用して3年経った僕らの現在地
onk
PRO
10
4.1k
【shownet.conf_】ネットワークテストの最適化と利便性の追求
shownet
PRO
0
310
Assisted reorganization of data structures
ennael
PRO
0
240
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
31
2.3k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
Building Better People: How to give real-time feedback that sticks.
wjessup
361
19k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
109
6.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
125
18k
From Idea to $5000 a Month in 5 Months
shpigford
380
46k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
4
110
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Mythical Team-Month
searls
218
43k
GraphQLとの向き合い方2022年版
quramy
43
13k
Music & Morning Musume
bryan
46
6.1k
For a Future-Friendly Web
brad_frost
174
9.3k
Transcript
͍·͔Β͡ΊΔECMAScript 6 by Shogo Sensui 2015.06.13 HTML5Φʔϧελʔζษڧձ https://www.flickr.com/photos/jakeandlindsay/5524669257
s Shogo Sensui a.k.a 1000ch
Profile WebϑϩϯτΤϯυΤϯδχΞ iOSωΠςΟϒΤϯδχΞ HTML5શൠ + Node.js + iOS/Mac #perfmatters
None
s ϑϩϯτΤϯυ ΤϯδχΞ ཆಡຊ
WEB+DB PRESS WebϑϩϯτΤϯυ ࠷લઢ
@cssradar @hiloki @t32k @1000ch @ahomu Frontend Weekly • ࠃ֎ͷϑϩϯτΤϯυใΛΩϡϨʔγϣϯ •
िʹҰਫ༵ʹ৴
@cssradar @hiloki @t32k @1000ch @ahomu Frontend Weekly • ࠃ֎ͷϑϩϯτΤϯυใΛΩϡϨʔγϣϯ •
िʹҰਫ༵ʹ৴ https://frontendweekly.tokyo
Agenda JavaScript ͱ ECMAScript ECMAScript 6 ͷओͳ৽ػೳ ECMAScript 6 ͱͷ͖߹͍ํ
·ͱΊ
JavaScript ͱ ECMAScript
1995ɺJavaScriptര Java͕ྲྀߦͬͯΔ͔Β JavaScriptͱ͍͏໊લʹ͠Α͏ Brendan Eichࢯ
ͳΜͩͱʁͬͪ͜JScriptͩʂ ͜Ε͕JavaScriptͩʂ ͯͯɺඪ४Խ͠Α͏…
ECMAScript JavaScript JScript ActionScript ඪ४Խ͞Εͨݴޠ༷ʢECMAScriptʣͱ ͦΕΛ࣮͢Δ֤ݴޠʢJavaScriptͳͲʣ ECMAScriptͷཱͪҐஔ
৭ʑͳҙݟ͕JavaScriptʹ Өڹ͖ͯͨ͠ etc…
ECMAScript 2015?
ECMAScript 6 ͷओͳ৽ػೳ https://www.flickr.com/photos/12355559@N03/18012486244
let const { var foo = 10; let bar =
100; const baz = 1000; console.log(foo, bar, baz); // => 10, 100, 1000 } console.log(foo, bar, baz); // => 10, undefined, undefined ES6
Arrow Functions $('button').on('click', function (e) { console.log(this); // => button
}); $('button').on('click', (e) => { console.log(this); // => window }); $('button').on('click', e => console.log(this)); ES5 ES6 ES6
import export // export.js export function foo() { console.log('foo'); }
export function bar() { console.log('bar'); } // import.js import { foo, bar } from './export.js'; foo(); // => foo bar(); // => bar ES6
Rest Parameters let x = 10, y = 20, z
= 30; function max(array) { return Math.max.apply(null, array); } max([x, y, z]); // => 30 function max(...array) { return Math.max.apply(null, array); } max(x, y, z); // => 30 ES6 ES6
Default Parameters function add(arg1, arg2) { if (arg1 === undefined)
{ arg1 = 0; } if (arg2 === undefined) { arg2 = 0; } return arg1 + arg2; } function add(arg1 = 0, arg2 = 0) { return arg1 + arg2; } ES5 ES6
let hundred = 100; let multiple = function (x, y)
{ return x * y; } console.log(`hundred is ${number}`); // => hundred is 100 console.log(`hundred * 10 is ${multiple(number, 10)}`); // => hundred * 10 is 1000 Template Strings ES6
function Human (message) { this.message = message; } Human.prototype.hello =
function () { console.log(this.message); } class Human { constructor(message) { this.message = message; } hello() { console.log(this.message); } } Class ES6 ES5
function* toThree() { yield 1; yield 2; return 3; }
console.log(toThree()); // => 1 console.log(toThree()); // => 2 console.log(toThree()); // => 3 Generator Functions ES6
Proxy var person = { firstName: 'Taro', lastName: 'Tanaka' };
var interceptor = { set: function (target, name, value, receiver) { console.log(name + ' is changed.'); target[name] = value; } get: function (target, name, receiver) { return name + ' is ' target[name]; } }; person = new Proxy(person, interceptor); ES6
Symbol var sym1 = Symbol(); var sym2 = Symbol("foo"); var
sym3 = Symbol("foo"); Symbol("foo") === Symbol("foo"); // => false ES6
Promise new Promise(function (resolve, reject) { resolve(10); }).then(function (value) {
return value * 10; }).then(function (value) { console.log(value); // 100 }); ES6
Set WeakSet var set1 = new Set([1, 2, 2, 3,
3, 3, 4, 4, 4, 4]); // => [1, 2, 3, 4] var set2 = new Set(set1); var set3 = new Set(set1.entries()); var set4 = new Set(set1.keys()); ES6
Map WeakMap var arrayKey = []; var map = new
Map(); map.set(1, 'This is a value'); map.set(arrayKey, 'This is also value'); map.get(1); // This is a value map.get(arrayKey); // This is also value ES6
ECMAScript 6 ͱͷ͖߹͍ํ https://www.flickr.com/photos/63771280@N08/18643164795/
※20156݄13࣌ × ×
ECMAScript 6 compatibility table
ES6͕ԿʹૉΒͯ͘͠ αϙʔτ͕ਐ·ͳ͍͜ͱʹ ಋೖͰ͖ͳ͍ʁ ×
ES6 ES5 τϥϯεύΠϥΛ͏ ES6ͷίʔυΛίϯύΠϧͯ͠ɺαϙʔτ͍ͯ͠ͳ͍ ϒϥβͰ࣮ߦՄೳͳίʔυʹม͢Δ
Traceur Compiler
Babel
ݶఆ͞ΕͨڥͰ͏ αϙʔτ͕ൺֱతਐΜͰ͍ΔChromeFirefoxͷ ֦ுػೳͰ͋Εࢥ͏ଘ͑Δ
AltJSͰऔΓೖΕ͍ͯ͘ TypeScriptFlowͰES6ͷߏจαϙʔτ͕ਐΜͰ͍Δ
Node.js 0.12ʙ ES6ͷػೳ͕--harmonyϑϥά͖Ͱར༻Մೳ iojsͳΒϑϥάෆཁʹͳ͍ͬͯΔ
·ͱΊ
ϒϥβαϙʔτ͕ ेʹͳΔͷ·ͩ·ͩઌͷ…
ཧ༝Λ͚ͭͯΒͳ͍ؒʹ ࣍ͳΔ༷(ES7ɾES8)͕ग़ͯ͘Δ
͑Δػೳ͔ΒঃʑʹऔΓೖΕͯ ࠓͷ͏ͪʹ׳Ε͍ͯ͘
͓ΘΓ +ShogoSensui 1000ch 1000ch