1It just checks the array,
2for the condition you gave,
3if atleast one element in the array passes the condition
4then it returns true
5else it returns false
1['one', 'two'].some(item => item === 'one') // true
2['one', 'two'].some(item => item === 'three') // false
1const age= [2,7,12,17,21];
2
3age.some(function(person){
4return person > 18;}); //true
5
6//es6
7const age= [2,7,12,17,21];
8age.some((person)=> person>18); //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
1const fruits = ['apple', 'banana', 'mango', 'guava'];
2
3function checkAvailability(arr, val) {
4 return arr.some(function(arrVal) {
5 return val === arrVal;
6 });
7}
8
9checkAvailability(fruits, 'kela'); // false
10checkAvailability(fruits, 'banana'); // true
1[2, 5, 8, 1, 4].some(isBiggerThan10); // false
2[12, 5, 8, 1, 4].some(isBiggerThan10); // true
3