loading...

Functional Programming.

asabeneh profile image Asabeneh ・1 min read

In this article I have covered everything you need to know about functional programming in JavaScript. Understanding the following features of JavaScript takes your JavaScript level to a higher level and it makes your JavaScript code shorter and cleaner. In addition, you will be able to solve complicated problems in a simpler way using this methods.

  1. forEach
  2. map
  3. filter
  4. reduce
  5. find
  6. findIndex
  7. some
  8. every

https://www.linkedin.com/pulse/functional-programming-asabeneh-yetayeh/

Discussion

pic
Editor guide
Collapse
chety profile image
Chety

Good post, but few things to mention

  • Map does not modify/mutate array, instead it returns a brand new array.

  • Reduce does not have a default value as 0. If you do not specify anything for second parameter, it will take caller array's first item as initial value[That's why it is recommended to specify a initial value ].

  • In your find example variable name is a kind of misleading.

const index = countries.find((country) => country.includes('o')) ; //wrong
const country = countries.find((country) => country.includes('o')) ; //right
  • There is a typo in some definition. You said if all elements satisfy criteria, then it returns true, otherwise it returns false.

By the way thanks for your efforts to make 30DaysOfJs for community, Kudos :)

Collapse
suprise_dr profile image
Suprise Nkosi

very interesting, how ever i dont think its everything, does it cover compositions, monads etc.

Collapse
asabeneh profile image
Asabeneh Author

The most frequent methods which you use either with vanilla JavaScript or React.