$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
初探 functional programming
Search
CypressKuo
February 03, 2017
Technology
0
110
初探 functional programming
CypressKuo
February 03, 2017
Tweet
Share
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
31
CSS_for_Web_Vitals.pdf
cypresskuo
0
37
談談_Code_review.pdf
cypresskuo
0
42
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
22
CSS_重構.pdf
cypresskuo
0
24
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
26
Core_Web_Vitals.pdf
cypresskuo
0
51
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
55
Webassembly.pdf
cypresskuo
0
11
Other Decks in Technology
See All in Technology
新 Security HubがついにGA!仕組みや料金を深堀り #AWSreInvent #regrowth / AWS Security Hub Advanced GA
masahirokawahara
1
1k
pmconf2025 - データを活用し「価値」へ繋げる
glorypulse
0
660
生成AI時代の自動E2Eテスト運用とPlaywright実践知_引持力哉
legalontechnologies
PRO
0
200
LLM-Readyなデータ基盤を高速に構築するためのアジャイルデータモデリングの実例
kashira
0
190
Bakuraku Engineering Team Deck
layerx
PRO
12
6.9k
技術以外の世界に『越境』しエンジニアとして進化を遂げる 〜Kotlinへの愛とDevHRとしての挑戦を添えて〜
subroh0508
1
350
生成AIでテスト設計はどこまでできる? 「テスト粒度」を操るテーラリング術
shota_kusaba
0
400
AI時代の開発フローとともに気を付けたいこと
kkamegawa
0
1.4k
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
0
170
Playwrightのソースコードに見る、自動テストを自動で書く技術
yusukeiwaki
12
4.6k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
乗りこなせAI駆動開発の波
eltociear
1
810
Featured
See All Featured
Become a Pro
speakerdeck
PRO
30
5.7k
4 Signs Your Business is Dying
shpigford
186
22k
Balancing Empowerment & Direction
lara
5
790
Docker and Python
trallard
47
3.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Into the Great Unknown - MozCon
thekraken
40
2.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.8k
Six Lessons from altMBA
skipperchong
29
4.1k
Fireside Chat
paigeccino
41
3.7k
Git: the NoSQL Database
bkeepers
PRO
432
66k
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