Implement zip in javascript
Reducing an array to a single value When we need to combine two arrays by progressively taking an item from each and combining the pair. If you visualize a zipper, where each side is...
Reducing an array to a single value When we need to combine two arrays by progressively taking an item from each and combining the pair. If you visualize a zipper, where each side is...
Reducing an array to a single value Often we have to iterate over the array by accessing multiple items at a time. For example, if you have to find the largest element in an...
Querying Nested Arrays To work with tree data structure we need to flatten them. We will be solving a problem using Array.prototype.forEach(). We will define Array.prototype.concatAll() using Array.prototype.forEach(). We will solve the same problem...
Problem Filter only those videos with a rating of 5.0 and return the id of such videos. Solution Further Reading Functional Programming
Predicating Arrays Filtering also key method for manipulating collections. We iterate over the array and add an item to the new array if it passes the test. We will be solving a problem using...
Projecting Arrays Applying a value to a function and getting a new value is called a projection. To project (transform) one array to another, we have to process each element in the array and...
This series of posts will train you how to use functional programming in javascript, which is the foundation of many modern javascript based frameworks. This post is a pre-requisite for the following posts on...
Problem Write a function Array.prototype.map() which can accept one additional argument. function mul(x) { return x * x; } console.log([1, 2, 3].map(mul)); // [1, 4, 9] Modify the function so that it can accept...
We need to understand closures first before we understand currying. closures allows inner function to access the variables in the outside function in which it is declared. Below MDN example explains it very well....