JS every


JS Array.every() method checks whether all array elements satisfy a specific function. It returns true or false.

var arr = new Array(1,2,3,4,5);
var ret = arr.every(function(x) {return x < 6;})
alert(ret); //true
ret = arr.every(function(x) {return x > 3;})
alert(ret); //false

Combine with other array methods:

var arr = new Array(1,2,3,4,5);
var ret = arr.slice(2,4).every(function(x) {return x > 2;})
alert(ret);  //true