Javascript Arrays and Functional Programming
zabanaa.github.io
Javascript Arrays and Functional Programming
1–10 of 92 posts
Re: Javascript Arrays and Functional Programming
#2Re: Javascript Arrays and Functional Programming
#3Re: Javascript Arrays and Functional Programming
#4It also seems wrong to mutate the accumulator in the reduce example, it would just be simpler to use `forEach` and use a variable defined outside if you're going to write code this way?
Re: Javascript Arrays and Functional Programming
#5 // Grab unique
[1,1,2,3,4].filter( ( item, index, array ) => array.indexOf( item ) === index )
// => [1,2,3,4]
// Flatten
[[1,2],[3,4]].reduce( ( result, item ) => result.concat(item), [] );
// => [1,2,3,4]
Not sure why the author missed `sort`. // Sort
[1,2,4,3].sort( ( a, b ) => a - b )Re: Javascript Arrays and Functional Programming
#6Great article, but questionable formatting: `return {name: player.name, age: player.age }` It also seems wrong to mutate the accumulator in the reduce example, it would just be simpler to use `forEach` and use a variable defined outside if you're going to write code this way?
1 : http://www.nicoespeon.com/en/2015/01/pure-functions-javascri...
Re: Javascript Arrays and Functional Programming
#7Most functional languages feature pattern matching, algebraic data types, purity, currying, strong typing, type inference, recursion instead of loops and types that cannot be null. It's a completely different style of coding. Adding map/filter/reduce to an imperative language doesn't get you close to the level of robustness and ease of implementation for that safety you'd get in a functional language.
Re: Javascript Arrays and Functional Programming
#8I accept that this is a widely used phrase now but I never understood why just using map/filter/reduce and avoiding state is enough for code to be called "functional programming". Most functional languages feature pattern matching, algebraic data types, purity, currying, strong typing, type inference, recursion instead of loops and types that cannot be null. It's a completely different style of coding. Adding map/fil…
I guess it could be called combinator-oriented programming or similar.
Re: Javascript Arrays and Functional Programming
#9I accept that this is a widely used phrase now but I never understood why just using map/filter/reduce and avoiding state is enough for code to be called "functional programming". Most functional languages feature pattern matching, algebraic data types, purity, currying, strong typing, type inference, recursion instead of loops and types that cannot be null. It's a completely different style of coding. Adding map/fil…
Because (a) we don't have an unambiguous definition of what functional programming is and (b) we don't have a better term for what this style of programming is. I guess it could be called combinator-oriented programming or similar.
Re: Javascript Arrays and Functional Programming
#10I have been wondering lately what is the value of articles like this. They do not convey any meaningful idea, they do not offer any useful insight on underlying matters; why do people even write something like this, except to litter the Internet even more? Anyone, who is distinctly familiar with functional programming or even just with the concept of higher order functions, surely knows those three basic primitives; those, who are not, would benefit much more from the basic concepts of first-class functions etc, than this random abrupt post.