array find javascript

JavaScript
const array1 = [5, 12, 8, 130, 44];

const found = array1.find(element => element > 10);

console.log(found);
// expected output: 12const inventory = [
  {name: 'apples', quantity: 2},
  {name: 'bananas', quantity: 0},
  {name: 'cherries', quantity: 5}
];

function isCherries(fruit) { 
  return fruit.name === 'cherries';
}

console.log(inventory.find(isCherries)); 
// { name: 'cherries', quantity: 5 }var ages = [3, 10, 18, 20];

function checkAdult(age) {
  return age >= 18;
}
/* find() runs the input function agenst all array components
   till the function returns a value
*/
ages.find(checkAdult);
 var ages = [3, 10, 18, 20];

function checkAdult(age) {
  return age >= 18;
}

function myFunction() {

    document.getElementById("demo").innerHTML = ages.find(checkAdult);
} myArray.find(x => x.id === '45').foo;/* returns first element of the array that satisfy the condition 
else returns undefined */
function isBigEnough(element) {
  return element >= 15;
}

[12, 5, 8, 130, 44].find(isBigEnough);
//expected output: 130
Source

Also in JavaScript: