Some Array Method Javascript
- Returns
true or false based on the provided callback
- Difference between Find Array Method Javascript
find() returns the value that satisfies the callback provided or undefined
Example
var operatives = [
{ id: 12, name: 'Baze Malbus', pilot: false },
{ id: 44, name: 'Bodhi Rook', pilot: true },
{ id: 59, name: 'Chirrut Îmwe', pilot: false },
{ id: 122, name: 'Jyn Erso', pilot: false }
];
var listHasPilots = operatives.some(function (operative) {
return operative.pilot;
});
// or
const listHasPilots = operatives.some(operative => operative.pilot);
console.log(listHasPilots) // true
Resources