Thank you for a very clear and concise article!
Hi Skay, thanks for the article.
There is an incorrect comment in your code:
//Higher order function - takes 'func' as an argument & returns a 'func' for execution
const higherOrderFunction = function(func, a, b) {
return func(a, b);
}
This function is not actually returning a function, but rather the result of the callback function, which is data.
A more concise example might be:
const sum = function(a, b) {
return a + b;
}
//Higher order function - takes 'func' as an argument & returns a 'func' for execution
const higherOrderFunction = (func) => (a, b) => {
return func(a, b);
}
const sumFor = higherOrderFunction(sum);
console.log(sumFor(2,3));
Here, higherOrderFunction takes func and returns a function, which then takes a,b and return data.
Cheers!
Thorough explanation and very refreshing which will help me in the interview process!
Well done!
Hi, the Array.find & Array.findIndex example, I didn't understand it clearly, so I decided to run it and I got a different output.
Luciana Murimi
Software Developer
Hi Skay Great article. Simple and concise.
Just a typo that I caught under Array.reduce syntax section:
Syntax: Array.every( callback( accumulator, currentValue, currentIndex, array)); -> theres .every instead of .reduce