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
初探 functional programming
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
CypressKuo
February 03, 2017
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
初探 functional programming
CypressKuo
February 03, 2017
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
38
CSS_for_Web_Vitals.pdf
cypresskuo
0
42
談談_Code_review.pdf
cypresskuo
0
50
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
25
CSS_重構.pdf
cypresskuo
0
29
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
32
Core_Web_Vitals.pdf
cypresskuo
0
57
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
63
Webassembly.pdf
cypresskuo
0
14
Other Decks in Technology
See All in Technology
チームで実践する AI-DLC 思考の軌跡を残すチェックポイント設計
belongadmin
0
2.8k
「コーディング」しない人のための Claude Code 入門 ChatGPT の次の一歩 — 業務に組み込む 育成・共有・自動化
rfdnxbro
2
1.2k
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
8
370
Cloud Run のアップデート 触ってみる&紹介
gre212
0
320
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1.2k
ChatworkとBPaaS 異なる特性で学んだAI機能開発の ベストプラクティス
kubell_hr
2
3k
運用を見据えたAIエージェント設計実践
amacbee
1
3.1k
AIを「創る」と「使う」の循環 — HRテックが実践するリアルなAI組織実装
taketo957
0
1.7k
ABEMA の Datadog × OTel 基盤、 中から見るか? 外から見るか?
tetsuya28
0
110
BigQuery の Cross-cloud Lakehouse への歩み
phaya72
2
590
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
270
サプライチェーンセキュリティの空白地帯 - 信頼できる”依存性”の未来を考える
rung
PRO
2
740
Featured
See All Featured
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
300
The browser strikes back
jonoalderson
0
1.1k
For a Future-Friendly Web
brad_frost
183
10k
From π to Pie charts
rasagy
0
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Designing for Performance
lara
611
70k
GitHub's CSS Performance
jonrohan
1033
470k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Transcript
初探 functional programming in JavaScript CypressKuo @前端組例會 2017/02/03 1
定義 一種程式設計的方法/概念 2
3
4
特色 ✣ Expression, no Statement ✣ First-class ✣ High order
function ✣ No side effect ✣ Referential transparency ✣ Pure Function 5
Expression, no Statement Expression Statement 6
First-class 函數與其他數據類型一樣,處於平等地位。 可以被賦值到其他變數, 也可以作為參數傳入到不同的函數中, 或者作為函數的回傳值。 7
8
9
10
High order function 滿足以下兩項其中之一的函數 ✣ 可以將函式當成參數傳入的函式 ✣ 可以將函式當成回傳值的函式 11
12
✣ .map() ✣ .filter() ✣ .reduce() ✣ .forEach() ✣ .some()
✣ .every() 常見的 High order function 13
No side effect 沒有與外部互動,產生與運算無關的其他結果。 ✣ 發送 http request ✣ 印出
console ✣ 取得使用者的 input 14
Referential transparency 不管外部環境如何,只要參數相同,函式執行的返回結果必定相同。 15
Pure Function 結合 no side effect 與 Referential transparency 一個
function 給予相同的參數, 永遠會回傳相同的返回值,並且沒有任何顯著的副作用 16
17
18
Function Composition ✣ Curry ✣ Compose 19
curry 將一個有 N 個參數的函數轉換成 N 個只有一個參數的函數 20
21
22
compose 把兩個以上的一個參數函數合併起來串聯多個組合成新的函數 23
24
25
優勢 ✣ 可讀性高 ✣ 可維護性高 ✣ 簡潔,開發快速 26
參考資料 http://blog.miniasp.com/post/2016/12/10/Functional-Programming-in-JavaScript.aspx?s=2 http://www.ruanyifeng.com/blog/2012/04/functional_programming.html http://www.slideshare.net/rockncoder/functional-programming-in-javascript-68835257 http://www.slideshare.net/ihower/fp-osdc2012v2 https://github.com/MostlyAdequate/mostly-adequate-guide http://ithelp.ithome.com.tw/articles/10186465 27