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
forループを越えて / beyond for loop
Search
Shunsuke Watanabe
October 12, 2018
Programming
590
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
forループを越えて / beyond for loop
#SurviveJS05 発表資料
高階関数を活用してコードを読みやすくする話です
Shunsuke Watanabe
October 12, 2018
More Decks by Shunsuke Watanabe
See All by Shunsuke Watanabe
いますぐ {id: number;} をやめろ
craftgear
1
380
Reactハンズオン 01 入門編 コード部分抜粋 / React Handson 01 components (excerpt)
craftgear
1
600
Reactハンズオン 02 redux編 コード部分抜粋 / React Handson 02 redux (excerpt)
craftgear
0
600
Reactハンズオン 01 入門編 コード部分抜粋 / React Handson 01 components (excerpt)
craftgear
0
730
Reactで作るDrupalサイト
craftgear
0
510
大阪Node学園 七時限目 「ゼロからはじめるnode.js」
craftgear
1
430
大阪Node学園 六時限目 「generator小咄」
craftgear
1
350
大阪Node学園四時限目 "This crazy testless world"
craftgear
1
350
Other Decks in Programming
See All in Programming
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
840
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
220
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
270
【やさしく解説 設計編 #1】「ドメイン駆動」と「実装駆動」ってなに? 〜設計の考え方を、たとえ話で学ぼう〜
panda728
PRO
1
100
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
200
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
480
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
act1-costs.pdf
sumedhbala
0
210
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
350
How to make the Groovebox
asonas
2
2.3k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.7k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
180
Side Projects
sachag
455
43k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
310
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
How to build a perfect <img>
jonoalderson
1
5.8k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
Amusing Abliteration
ianozsvald
1
220
Odyssey Design
rkendrick25
PRO
2
730
Transcript
forϧʔϓΛ͑ͯ ลढ़ี ˏcraftgear
ߴ֊ؔͬͯ ͝ଘͰ͔͢ʁ
ߴ֊ؔͱ ͨͱ͑ɺ
ؔΛҾʹऔΔ ؔ $('#button').click( e => { console.log(e); } );
ؔΛΓͱ͠ ͯฦؔ͢ const createCounter = () => { var number
= 0; return () => { number++; return number; }; }
Array.map(fn)
forϧʔϓͰͳ ͯ͘mapϝιο υΛ͏ཧ༝
ίʔυ ͷ ҙਤ
const a = [1,2,3].map(fn)
Γaͷܕ ྻͰɺ ཁૉ̏
ྻͷ֤ཁૉ ʹରͯ͠fnΛ ࣮ߦ͍ͯ͠Δ
ԿΛΓ͍ͨ ͔fnͷதΛ ಡΊΘ͔Δ
Θ͔Γ͍͢ ί ʔ υ ɺॏཁɻ
ϝϯς͕༰қ ฏͳίʔυ ϨϏϡʔ
fnΛΓग़ ͯ͠ςετ
࣭ ্
UIߏங ʹศར
const dummyTodos = [ { id: 1, title: 'aaaa', done:
true }, { id: 2, title: 'aaaa', done: false }, ]; const TodoList = ({ todos }) => ( <div> {todos.map(todo => ( <TodoItem key={todo.id} {...todo} /> ))} </div> );
map͚ͩ ͡Όͳ͍
map(f) filter(f) reduce(f, init) forEach(f) ྻ [n] [n] [n] [n]
Γ [n] [<= n] initͱಉܕ ͳ͠
some(f) every(f) findIndex(f) find(f) ྻ [n] [n] [n] [n] Γ
ਅِ ਅِ ཁૉҰͭ
༻্ͷҙ
filterʹ͢fn͕ฦ͢ ਅِͰ͋Δ͜ͱ -1falseʹͳΒͳ͍
[].some [].every ৗʹtrue ʮۭڏʹਅʯ
ඇಉظॲཧ Promise.all()Ͱ
reduce ΄Ͳ΄Ͳʹ
chainingͱ compositionͰ ֦͕Δੈք
const double = v => v * 2 const over5
= v => v > 5 const a = [1,2,3] .map(double) .filter(over5)
import * as R from 'ramda'; const doubleOver5 = R.compose(
R.filter(over5), R.map(double) );
const b = doubleOver5([2, 3, 4]); const c = doubleOver5(
{a: 1, b: 2, c: 3} );
࣮ԋ
Thank You!