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
880
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
290
First Steps into Functional Programming
vakila
7
2.5k
The Language of Programming
vakila
4
740
Recursion, Iteration, & JavaScript: A love story
vakila
1
490
From Big Band Web App to Serverless Bebop
vakila
0
550
Embracing Constraints
vakila
1
250
Programming across paradigms
vakila
1
780
Immutable data structures for functional JavaScript
vakila
7
1.9k
Functional Programming: What? Why? How?
vakila
1
340
Other Decks in Programming
See All in Programming
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
150
FDEが実現するAI駆動経営の現在地
gonta
2
270
仕様駆動開発の消費期限
watany
17
7.5k
Foundation Models frameworkで画像分析
ryodeveloper
1
600
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
210
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
870
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
100
Built Our Own Background Agent at LayerX
layerx
PRO
9
5.1k
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
170
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
200
YesSQL, Process and Tooling at Scale
rocio
174
15k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
400
RailsConf 2023
tenderlove
30
1.5k
The Language of Interfaces
destraynor
162
27k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
370
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
790
Accessibility Awareness
sabderemane
1
170
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Curious Case for Waylosing
cassininazir
1
450
Practical Orchestrator
shlominoach
191
12k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
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