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);
//The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
const array1 = [5, 12, 8, 130, 44];

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

console.log(found);
// expected output: 12 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;
Source

Also in JavaScript: