Skip to content
Advertisement

Tag: functional-programming

How do I `.filter()` an array/object and return a new array with the original keys and not as an indexed array/object as filter return?

I want to filter all (“isActive” === 0) but keep the key set the same (which is equal to the user id) when returning the newObj: This is what I have now: which returns indexed keys no for loops (unless the ES6 .forEach() is a must). I would like an ES6 approach to this problem using filter/map/reduce if possible in

Currying a function that takes infinite arguments

Using ES5, how do you curry a function that takes infinite arguments. The function above takes only three arguments but we want our curried version to be able to take infinite arguments. Hence, of all the following test cases should pass: Here is the solution that I came up with: However, I have been told that it’s not very “functional”

Can anyone explain me what is state and mutable data?

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. http://en.wikipedia.org/wiki/Functional_programming Can anyone explain me what is state and mutable data? Can anyone give me examples in either JAVA or JavaScript. Answer mutable suggest anything that can change, i.e. an int In java a string is

Advertisement