Node.js examples for Array:Array Operation
Predicate Every and Some on array
function every(array, test) { for (var i=0;i<array.length;i++){ if (test(array[i]) != true) { return false; }/*w w w .jav a2 s. c om*/ } return true; } function some(array, test) { for (var i=0;i<array.length;i++){ if (test(array[i]) === true) { return true; } } return false; } console.log(every([NaN, NaN, NaN], isNaN)); // true console.log(every([NaN, NaN, 4], isNaN)); //false console.log(some([NaN, 3, 4], isNaN)); // console.log(some([2, 3, 4], isNaN)); //