If I have a function like isNumber(x) that returns true if x is a number, then I can use the function written above to apply the isNumber function to an array.
function forEach(array, function)
var newArray = new Array();
for(var i=0; i < array.length; i++)
newArray[i] = function(this[i]);
But what if I want to apply a function that has multiple parameters? For example sum(a,b) that adds a and b and I would want that function to add all numbers in an array. Or maybe a function like isBetween(x,a,b) that would return true if x is between a and b and I want to be able to do something like forEach(array, isBetween(a,b)) which would check if each element is between a and b. Is there a way to do this?
var arr = [1, 2, "three", 4, "five"];
var boolArr = forEach(arr, isNumber);
//boolArr = [true, true, false, true, false]