Skip to content

Instantly share code, notes, and snippets.

@aswebdev
Last active August 29, 2015 14:00
Show Gist options
  • Save aswebdev/3323f1d84ddf6053bafd to your computer and use it in GitHub Desktop.
Save aswebdev/3323f1d84ddf6053bafd to your computer and use it in GitHub Desktop.
Looping a JavaScript array as per a PHP array_map
var set1 = [2, 4, 6, 8, 10];
var set2 = [2, 4, 5, 8, 10];
console.log(set1.every(function (a) {
return a % 2 === 0;
})); // true
console.log(set2.every(function (a) {
return a % 2 === 0;
})); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment