1const array = [1, 2, 3, 4, 5];
2// checks whether an element is even
3const even = (element) => element % 2 === 0;
4console.log(array.some(even));
5// expected output: true
1let array = [1, 2, 3, 4, 5];
2
3//Is any element even?
4array.some(function(x) {
5 return x % 2 == 0;
6}); // true
1
2// There's no isEmpty or any method.
3// You can define your own .isEmpty() or .any()
4
5Array.prototype.isEmpty = function() {
6 return this.length === 0;
7}
8
9Array.prototype.any = function(func) {
10 return this.some(func || function(x) { return x });
11}