some function js code example
Example 1: javascript array some
let array = [1, 2, 3, 4, 5];
array.some(function(x) {
return x % 2 == 0;
});
Example 2: js some
movies.some(movie => movie.year > 2015)
Example 3: some js
[2, 5, 8, 1, 4].some(isBiggerThan10);
[12, 5, 8, 1, 4].some(isBiggerThan10);
Example 4: js object some
let obj = {"num1":1, "num2":2, "num3":3, "num4":4, "num5":5};
var firstEven = null;
Object.values(obj).some((item) => {
if (item == 2) {
firstEven = item;
}
return item % 2 == 0;
});