Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Node v6 with ES2015
Pine Mizune
June 03, 2016
Programming
1
670
Node v6 with ES2015
Gotanda.js #4 in Retty で発表した資料
http://gotandajs.connpass.com/event/30961/
Pine Mizune
June 03, 2016
Tweet
Share
More Decks by Pine Mizune
See All by Pine Mizune
多言語対応と絵文字ジェネレーター / i18n of Emoji Generator
pine
0
400
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
840
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
430
Lerna による明示的疎結合アーキテクチャ
pine
1
530
CircleCI 2.0 x JavaScript
pine
3
470
Perl 卒業式
pine
0
270
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
390
Emoji Generator meets Browser Extensions
pine
1
2.7k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.4k
Other Decks in Programming
See All in Programming
Maintaining Software Correctness
dlew
PRO
3
240
BASE BANKチームの技術選定と歴史 / how to decide technology selection for startup
budougumi0617
0
180
iOS 16からのロック画面Widget争奪戦に備える
tsuzuki817
0
190
GoogleI/O2022 LT報告会資料
shinsukefujita1126
0
290
Android スキルセットをフル活用して始めるスマートテレビアプリ開発
satsukies
1
190
GitHubのユーザー名を変更した後のあれこれ
tahia910
0
120
Gitlab CIでMRを自動生成する
forcia_dev_pr
0
110
Branching out to Jetpack Compose
chrisbanes
4
1.2k
言語処理ライブラリ開発における失敗談 / NLPHacks
taishii
1
430
Android Tools & Performance
takahirom
1
430
Custom Design Systems in Compose UI
rharter
5
520
Reactive Java Microservices on Kubernetes with Spring and JHipster
deepu105
1
170
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
15k
Visualization
eitanlees
124
11k
What’s in a name? Adding method to the madness
productmarketing
11
1.6k
Happy Clients
brianwarren
89
5.6k
How to train your dragon (web standard)
notwaldorf
58
3.9k
4 Signs Your Business is Dying
shpigford
169
20k
A Modern Web Designer's Workflow
chriscoyier
689
180k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
Adopting Sorbet at Scale
ufuk
63
7.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
344
17k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
351
21k
Transcript
3 Jun, 2016 / Gotanda.js #4 in Retty Pine Mizune
Node v6 with ES2015
Profile o GitHub: @pine o Twitter: @pine613 o 好きな言語: JavaScript
o 仕事で書いている言語: Kotlin / Perl o Mobile Factory, Inc
Table of contents uNode v6 released uDestructuring assignment (分割代入) uDefault
parameters uRest parameters (残余引数) uProxy API uReflect API Node v6 ~ 対応
Table of contents uNode v6 released uDestructuring assignment (分割代入) uDefault
parameters uRest parameters (残余引数) uProxy API uReflect API Node v6 ~ 対応
Node v6 released [1/4] 04/26 次期 LTS 候補 Node v6
リリース • 2013/03/11 Node v0.10.0 released • 2015/02/06 Node v0.12.0 released • 2015/09/08 Node v4.0.0 released (LTS) • 2015/10/29 Node v5.0.0 released • 2016/04/26 Node v6.0.0 released (次期 LTS) 今日はこの話
Node v6 released [2/4] 04/26 次期 LTS 候補 Node v6
リリース Node v0.10.x / v0.12.x は 2016 年中でサポート切れ
Node v6 released [3/4] 04/26 次期 LTS 候補 Node v6
リリース Node v4.x (LTS) は 2018 年春までサポート
Node v6 released [4/4] 04/26 次期 LTS 候補 Node v6
リリース Node v6.x なら ES2015 が ほぼトランスパイル不要
Table of contents uNode v6 released uDestructuring assignment (分割代入) uDefault
parameters uRest parameters (残余引数) uProxy API uReflect API Node v6 ~ 対応
Destructuring assignment (分割代入) [1/3] 配列、オブジェクトの代入を簡潔に記述する構文 let [ first, second ]
= [ 1, 2 ] console.log(first, second) #=> 1 2 let { name, age } = { name: “rem”, age: 17 } console.log(name, age) #=> rem 17 配列での分割代入 オブジェクトでの分割代入
Destructuring assignment (分割代入) [2/3] 関数の引数でも、分割代入が可能 function foo({ flag = false
} = {}) { console.log(flag) } foo() #=> false foo({ flag: true }) #=> true オプションを受け取る関数が、簡潔に定義可能 呼び出す側は今まで通り
Destructuring assignment (分割代入) [3/3] require / import 文で使うと綺麗 const {assign}
= require(‘lodash’) import/export は Node v6 では非対応、要 Babel require での記述が簡略化可能 import {exec} from ‘child_process’
Default parameters 関数の引数に初期値が設定可能 function foo(a = 1, b, c =
3) { console.log(a, b, c) } 任意の箇所の引数の初期値が指定可能 foo() #=> 1 undefined 3 foo(1, 2, 3) #=> 1 2 3 初期値を指定しない場合は従来通り undefined
Rest parameters (残余引数) 可変長引数を簡潔に記述可能 function foo(a, b, …args) { console.log(a,
b, args) } 任意の箇所の引数の初期値が指定可能 foo(1, 2) #=> 1 2 [] foo(1, 2, 3, 4, 5) #=> 1 2 [ 3, 4, 5 ] arguments と違い本物の配列として扱える
Proxy API [1/2] プロパティアクセスや演算子の処理を上書きする機能 const target = { foo: ‘foo’
} const proxy = new Proxy(target, { get(target, name) { return ‘bar’ } }) プロパティアクセスを上書きする場合 console.log(target.foo) #=> foo console.log(proxy.foo) #=> bar Proxy 経由でのアクセスのみ上書きされる ※ Babel 未対応
Proxy API [2/2] Proxy API で上書き可能な処理な例 名前 上書きできる処理 get obj[‘key’]
set obj[‘key’] = value has ’key’ in obj apply obj() constructor new obj() enumerate for (var key in obj) { ... }
Reflect API Proxy の各処理に対応する関数を提供する API const target = { foo:
‘foo’ } const proxy = new Proxy(target, { get(target, name) { return Reflect.get(target, name) } }) Proxy とセットで用いると有用 console.log(target.foo) #=> foo console.log(proxy.foo) #=> foo Proxy から本来の処理に移譲できている
Fin. ALLPPT.com _ Free PowerPoint Templates, Diagrams and Charts