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
Node v6 with ES2015
Search
Pine Mizune
June 03, 2016
Programming
1
720
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
630
C++ 製グラフィックライブラリ Skia の紹介 / Introduction to the graphics library Skia written by C++
pine
0
1.3k
asyncio + aiohttp で作るウェブサービス / How to develop a web service with asyncio and aiohttp
pine
0
580
Lerna による明示的疎結合アーキテクチャ
pine
1
580
CircleCI 2.0 x JavaScript
pine
3
500
Perl 卒業式
pine
0
290
Android Studio の気になる warnings を抑制する方法まとめ
pine
0
450
Emoji Generator meets Browser Extensions
pine
1
2.9k
近年の OSS 開発における CI 選択のベストプラクティス
pine
3
4.5k
Other Decks in Programming
See All in Programming
Ruby Function Composition
bkuhlmann
1
330
Elm Form Validation
bkuhlmann
0
510
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
820
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
8
4k
Fragment Composition of GraphQL
quramy
4
800
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
240
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
170
Elm 0.19.0 Changes
bkuhlmann
0
490
Java 22 Overview
kishida
1
180
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
340
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
230
Node.js v22 で変わること
yosuke_furukawa
PRO
9
3.1k
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
The Mythical Team-Month
searls
216
42k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
274
13k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
Web development in the modern age
philhawksworth
202
10k
What's in a price? How to price your products and services
michaelherold
237
11k
Fireside Chat
paigeccino
21
2.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
37
2.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
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