KEMBAR78
Functional javascript | PDF
Functional
JavaScript
William Bruno
Desenvolvedor NodeJS
http://wbruno.com.br/
http://github.com/wbruno
wbrunom@gmail.com
@wbrunom
Forget it!
Functional Programming
Dividir um problema em probleminhas menores
https://blog.taller.net.br/programacao-funcional-parte1/
How smaller?
Transparência

Pureza
Imutabilidade
https://www.slideshare.net/webf/functional-programming-with-javascript
Why?
Funções Puras

Evitar side effects
Evitar estados (dados imutáveis)
Programar de forma declarativa

Reduzir complexidade
Composição
Lazy Evaluation
https://www.slideshare.net/webf/functional-programming-with-javascript
loops
.forEach()
loop
.forEach()
inject pure function
.map()
creates a new array of same length
.map()
creates a new array of same length
.map()
creates a new array of same length
.map()
creates a new array of same length
.filter()
creates a new array with elements that passes
.find()
finds the match
.reduce()
applies a function against a accumulator,
to reduce to a single value
.some()
test if some element passes, returns boolean
.every()
test if every element passes, returns boolean
.includes()
@deprecated indexOf
.pop(), .push(), .shift(), .unshift()
removes or add the last or first element of array
Lazy.js
eval only when needed
http://danieltao.com/lazy.js/
What else?
Monad (maybe, just, etc)

Pipes (composition)

Currying
https://medium.com/tableless/entendendo-programa%C3%A7%C3%A3o-funcional-em-javascript-de-uma-vez-c676489be08b
Obrigado
Functional javascript

Functional javascript