Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Learning Functional Programming with JavaScript
Search
Anjana Sofia Vakil
April 24, 2016
Programming
0
840
Learning Functional Programming with JavaScript
Given at JSUnconf 2016 (
http://2016.jsunconf.eu/
)
Anjana Sofia Vakil
April 24, 2016
Tweet
Share
More Decks by Anjana Sofia Vakil
See All by Anjana Sofia Vakil
The Art of Functional Programming
vakila
0
220
First Steps into Functional Programming
vakila
7
2.4k
The Language of Programming
vakila
4
650
Recursion, Iteration, & JavaScript: A love story
vakila
1
440
From Big Band Web App to Serverless Bebop
vakila
0
520
Embracing Constraints
vakila
1
210
Programming across paradigms
vakila
1
740
Immutable data structures for functional JavaScript
vakila
7
1.8k
Functional Programming: What? Why? How?
vakila
1
300
Other Decks in Programming
See All in Programming
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
2
650
Cap'n Webについて
yusukebe
0
120
Go コードベースの構成と AI コンテキスト定義
andpad
0
120
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
360
sbt 2
xuwei_k
0
260
生成AIを利用するだけでなく、投資できる組織へ
pospome
0
240
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
5.5k
チームをチームにするEM
hitode909
0
290
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.7k
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
310
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
6.9k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Statistics for Hackers
jakevdp
799
230k
Balancing Empowerment & Direction
lara
5
790
The Art of Programming - Codeland 2020
erikaheidi
56
14k
[SF Ruby Conf 2025] Rails X
palkan
0
500
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
93
Measuring & Analyzing Core Web Vitals
bluesmoon
9
700
Six Lessons from altMBA
skipperchong
29
4.1k
GitHub's CSS Performance
jonrohan
1032
470k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Bash Introduction
62gerente
615
210k
Docker and Python
trallard
47
3.7k
Transcript
Learning Functional Programming with JS @AnjanaVakil
The Recurse Center https://www.recurse.com/
What is functional programming?
What is functional programming? a programming paradigm
What is functional programming? a coding style
What is functional programming? a mindset
What is functional programming? a sexy, buzz-wordy trend
Why functional JavaScript?
Why functional JavaScript? object-oriented JS gets tricky (prototypes? this?!?)
Why functional JavaScript? safer, easier to debug/maintain
Why functional JavaScript? established community
OK, let’s do it!
OK, let’s do it! ...how?
Do everything with functions input -> output
Not functional: var name = “Anjana”; var greeting = “Hi,
I’m ”; console.log(greeting + name); => “Hi, I’m Anjana”
Functional: function greet(name) { return “Hi, I’m ” + name;
} greet(“Anjana”); => “Hi, I’m Anjana”
Avoid side effects use “pure” functions
Not pure: var name = “Anjana”; function greet() { console.log(“Hi,
I’m ” + name); }
Pure: function greet(name) { return “Hi, I’m ” + name;
}
Use higher-order functions functions can be inputs/outputs
function makeAdjectifier(adjective) { return function (string) { return adjective +
“ ” + string; }; } var coolifier = makeAdjectifier(“cool”); coolifier(“conference”); => “cool conference”
Don’t iterate use map, reduce, filter
http://www.datasciencecentral.com/forum/topics/what-is-map-reduce
Avoid mutability use immutable data
Mutation (bad!): var rooms = [“H1”, “H2”, “H3”]; rooms[2] =
“H4”; rooms; => ["H1", "H2", "H4"]
No mutation (good!): var rooms = [“H1”, “H2”, “H3”]; Var
newRooms = rooms.map(function (rm) { if (rm == “H3”) { return “H4”; } else { return rm; } }); newRooms; => ["H1", "H2", "H4"] rooms; => ["H1", "H2", "H3"]
Persistent data structures for efficient immutability Mori, Immutable.js
Ready to try it out?
FP libraries for JS • Mori (http://swannodette.github.io/mori/) • Immutable.js (https://facebook.github.
io/immutable-js/) • Underscore (http://underscorejs.org/) • Lodash (https://lodash.com/) • Ramda (http://ramdajs.com/) • ...and more!
Want to learn more?
“An introduction to functional programming” by Mary Rose Cook https://codewords.recurse.com/issues/one/an-introduction-to-functional-programming
Thanks for listening! I’m @AnjanaVakil Huge thanks to: JSUnconf organizers
Diversity sponsors The Recurse Center & alums