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
Learning Functional Programming with JavaScript
Search
Anjana Sofia Vakil
April 24, 2016
Programming
860
0
Share
Learning Functional Programming with JavaScript
Given at JSUnconf 2016 (
http://2016.jsunconf.eu/
)
Anjana Sofia Vakil
April 24, 2016
More Decks by Anjana Sofia Vakil
See All by Anjana Sofia Vakil
The Art of Functional Programming
vakila
0
250
First Steps into Functional Programming
vakila
7
2.5k
The Language of Programming
vakila
4
710
Recursion, Iteration, & JavaScript: A love story
vakila
1
470
From Big Band Web App to Serverless Bebop
vakila
0
540
Embracing Constraints
vakila
1
230
Programming across paradigms
vakila
1
770
Immutable data structures for functional JavaScript
vakila
7
1.8k
Functional Programming: What? Why? How?
vakila
1
320
Other Decks in Programming
See All in Programming
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
150
ハーネスエンジニアリングとは?
kinopeee
10
5.4k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
190
実用!Hono RPC2026
yodaka
2
230
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
220
NakouPAY説明用
annouim0
0
180
t *testing.T は どこからやってくるの?
otakakot
1
660
Angular Signal Forms
debug_mode
0
110
10 Tips of AWS ~Gen AI on AWS~
licux
5
410
The Less-Told Story of Socket Timeouts
coe401_
3
350
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
150
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
210
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
3k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
510
Google's AI Overviews - The New Search
badams
0
980
First, design no harm
axbom
PRO
2
1.2k
Mind Mapping
helmedeiros
PRO
1
150
Evolving SEO for Evolving Search Engines
ryanjones
0
180
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
530
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
270
Information Architects: The Missing Link in Design Systems
soysaucechin
0
890
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
340
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