© Yariv Gilad
© Yariv Gilad
It is a programming paradigm
(like imperative, OOP etc…)
© Yariv Gilad
It is a coding style,
a way to organize your code...
© Yariv Gilad
It is a mindset,
a way of thinking about a problem
or an attitude while approaching a task
© Yariv Gilad
© Yariv Gilad
Because there must be
a better way then writing
OOP in JS...
JavaScript is not Java!
© Yariv Gilad
Because FP is an easier mental model
input => output
and JS is a good fit for it
© Yariv Gilad
FP is predictable => easier to test & Maintain
Write less code
with less bugs
in less time!
© Yariv Gilad
Reuse your code
using Function composition
Your app is made out of small testable units
you can use and reuse all over
© Yariv Gilad
Because it has a vibrant community
full of references and support
© Yariv Gilad
© Yariv Gilad
input => output
© Yariv Gilad
var name = "Ajar";
var greeting = "Hi, I'm ";
console.log(greeting + name);
// => "Hi, I'm Ajar"
© Yariv Gilad
function greet(name) {
return "Hi, I’m " + name;
}
greet("Ajar");
// => "Hi, I’m Ajar"
© Yariv Gilad
a Side effect is referencing or modifying anything outside of a function scope, its input or output
Side effects leads to unpredictable buggy code
© Yariv Gilad
var name = "Ajar";
function greet() {
console.log("Hi, I’m " + name);
}
© Yariv Gilad
function greet(name ) {
return "Hi, I’m " + name;
}
© Yariv Gilad
© Yariv Gilad
function makePrefixer(prefix) {
return function (string) {
return prefix + " " + string;
}
}
var coolifier = makePrefixer("cool");
coolifier("workshop");
// => "cool workshop"
var awesomer = makePrefixer("awesome");
awesomer ("workshop");
// => "awesome workshop"
© Yariv Gilad
© Yariv Gilad
© Yariv Gilad