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
PHPerから見た昨今のJSについて
Search
polidog
March 14, 2015
Technology
0
440
PHPerから見た昨今のJSについて
polidog
March 14, 2015
Tweet
Share
More Decks by polidog
See All by polidog
小さな開発会社を作った理由
polidog
1
2.4k
小さな開発会社がWebサービスを作る理由
polidog
1
510
トランザクションスクリプトは何がダメなのか?
polidog
2
2.9k
React初心者がHooksを理解するためにコードを読んでみた
polidog
0
480
object-mapperを作ってる話
polidog
0
290
2020年から始めるSymfonyフレームワーク
polidog
2
1.2k
はじめてのモダンPHP
polidog
0
550
ソフトウェア設計は難しくない
polidog
3
950
柔軟なアプリケーションをSymfonyで作るために考えている事
polidog
1
3k
Other Decks in Technology
See All in Technology
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
いざ、BSC討伐の旅
nikinusu
2
780
Application Development WG Intro at AppDeveloperCon
salaboy
0
190
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
150
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
310
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
Taming you application's environments
salaboy
0
190
Terraform Stacks入門 #HashiTalks
msato
0
360
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Scaling GitHub
holman
458
140k
GitHub's CSS Performance
jonrohan
1030
460k
Being A Developer After 40
akosma
86
590k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
What's new in Ruby 2.0
geeforr
343
31k
Six Lessons from altMBA
skipperchong
27
3.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Building Applications with DynamoDB
mza
90
6.1k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Transcript
PHPer͔ΒݟͨࡢࠓͷJSʹͭ ͍ͯ ੩ԬJavaScriptษڧձ #3 @polidog
ࣗݾհ • ϙϦυοάͰ͢ɻ݄ྋଠͬͯݴ͍·͢ɻ • ਗ਼ਫࢢੜ·Εɻਗ਼ਫ۠ҭͪɻ • PHPerͰ͢ɻJS࣌ʑॻ͖·͢ɻ • SymfonyϢʔβʔձͷਓʹͳΓ·ͨ͠ɻ •
λϰΟίϜגࣜձࣾͰΤϯδχΞͬͯ·͢ɻ
ࠓ͍ͨ͜͠ͱ
ͦͷલʹએ
λϰΟίϜͰɺgotripͱ͍ ͏ϝσΟΞͬͯ·͢ɻ http://gotrip.jp/
Symfony Meetup։࠵͠· ͢ʂ https://symfony.doorkeeper.jp/events/ 21692
ࠓ͍ͨ͜͠ͱ
ECMA Script6!!
– @nakajmg “ࠓ͔Β֮͑ΔͳΒCoffeeScriptΑΓES6 ͩΑɻ”
ͱ͜ΖͰESͬͯʁ
–ɹWikipediaΑΓ “Ecma InternationalʹΑͬͯඪ४Խ͞Ε ͨεΫϦϓτݴޠͰ͋Δɻ࣮͝ͱͷޓ ੑ͕͍ JavaScript ྨʢಛʹ JScriptʣ ͷඪ४ΛఆΊͨͷͰ͋Δɻ”
ES6ͰՃ͞ΕΔ
Features https://github.com/lukehoban/es6features
ࠓ͢ػೳ 1. ؔ(Arrow functions,Function Argumentss) 2. ม(let + const) 3.
Ϋϥε(classes) 4. δΣωϨʔλͱfor of 5. άϩʔόϧΦϒδΣΫτ(Map,Set, WeakMap, WeakSet) 6. Promises
1. ؔ var test = a => { console.log(“execute!! :
”+a); } function a(x, y=12) { } function b(x, ...y) { } function c(x,y,z) {} args = [1,2,3] c(…args);
1. ؔ(ArrowFunctions) =>ΛͬͯؔఆٛͰ͖Δ Ҿෳ (a,b) => ͱͳΔ ෳߦͷ߹{}Λ͏
1. ؔ(FunctionArguments) ؔύϥϝʔλʹʹσϑΥϧτ͕ઃఆͰ͖ Δɻ ՄมҾΛ…argsͰࢦఆͰ͖Δɻ ྻΛؔҾʹల։Ͱ͖Δɻ
2. ม let hoge = 1; const fuga = 2;
2. ม letΛ͏ͱϒϩοΫείʔϓ͕࣮ݱͰ͖Δɻ constΛ͏ͱ্ॻ͖Ͱ͖ͳ͍ɻ
3. Ϋϥε class Hoge { } var hoge = new
Hoge();
3. Ϋϥε ΫϥεએݴͰॻ͚Δɻ extendsͰܧঝͰ͖Δɻ superͰܧঝݩͷϝιουݺͼग़ͤΔɻ
4. δΣωϨʔλͱfor of let gen = function*() { for(let i
= 0; i < 10; i++) { yield i+10; } } for (let i of gen()) { console.log(i) }
4. δΣωϨʔλͱfor of function* ͱ yieldΛ͏ for of ͰϧʔϓͰ͖Δ ArrowFunctionͱΈ߹ΘͤΒΕͳ͍
5. άϩʔόϧΦϒδΣΫτ var set = new Set(); set.add(“hoge”).add(“fuga”) var map
= new Map(); map.set(“hoge”,10); map.set(“fuga”,20);
5. άϩʔόϧΦϒδΣΫτ Set Map WeakSet WeakMap ͕͑Δɻ
6. Promises function timeout(duration = 0) { return new Promise((resolve,
reject) => { setTimeout(resolve, duration); }) } var p = timeout(1000).then(() => { return timeout(2000); }).then(() => { throw new Error("hmm"); }).catch(err => { return Promise.all([timeout(100), timeout(200)]); })
6. Promises http://azu.github.io/promises-book/
Ͳ͏ͬͯಈ͔͢ͷʁ
ECMAScript 6 compatibility table http://kangax.github.io/compat-table/es6/
େ͖͚ͯ̎ͭ͘ • αʔόαΠυͰ࣮ߦ͢Δ • τϥϯείϯύΠϥΛར༻͢Δ
αʔόαΠυͰಈ͔ͯ͠ΈΑ ͏ɻ
IUUQTJPKTPSHKBJOEFYIUNM
͜Μͳײ͡Ͱ࣮ߦ͢Δ $ iojs --harmony_classes ./classes.es6.js $ iojs --harmony_arrow_functions ./arrows.js $
iojs --es_staging ./hoge.js
iojs͏ͱ͖ʹҙ
Φϓγϣϯ(flag)͕ඞཁ • shipping features → ϑϥάඞཁͳ͍ • staged features →
--es_staging͕ඞཁ • in progress features → ݸผʹϑϥάࢦఆ͕ඞ ཁ
ϑϥάΛௐΔ $ iojs --v8-options | grep harmony
ΊΜͲ͍͔͘͞Βશ෦ͷϑϥ άΛࢦఆͯ͠ΈΔɻ $ iojs $(iojs --v8-options | grep harmony |
sed -e 's/(.*)\(.* \)/ /g' | tr '\n' ' ‘) ./hoge.js
ৄ͍͠ࣄiojsͷαΠτͷ͜ ͜Λ֬ೝ͠·͠ΐ͏ɻ https://iojs.org/ja/es6.html
τϥϯείϯύΠϥ
IUUQTCBCFMKTJP
gulpͱΈ߹ΘͤͯΈ·͠ΐ ͏ɻ
“Ұ൪ॏཁͳͷָ͘͠ॻ͚Δ͔Ͳ͏͔ͬ ͯ͜ͱɻ”