Functional Javascript
Functional Programming
• First-class and higher-order functions
• Pure functions
• Lazy evaluation
• Recursion
Is Javascript functional?
functional enough.
Pure Javascript Functions
• Array.prototype.map - converts array to a new
array
• Array.prototype.filter - remove elements from
array
• Array.prototype.reduce - converts values from an
array into one value
Map / Filter / Reduce
Demo Filter + Map
Demo Reduce
Currying
• Break down a multiple argument function to a
function that takes part of the arguments
Ramda
• Immutability is at the heart of the design
• All the functions are automatically curried
Ramda - adding
Demo - addition vanilla JS
Demo - addition with currying

Functional javascript

Editor's Notes

  • #3 Closures, functions as arguments and anonymous functions. Higher-order functions are functions that either take another function as the input or return a function as the output. Pure functions - no side effects and immutable data Lazy - It doesn’t support lazy evaluation natively, you have to use workarounds / frameworks like Lazy.js Recursion - good support but due to how closures manages memory, it uses up lot’s of memory
  • #4 It’s functional enough due to the fact that functions are first-class in JS.