How to use JavaScript Array some()

Program to use JavaScript Array some() method


function a(b) {
    return b < 18;
}

let c = [44, 23, 37, 60, 75];
let d = c.some(a);

console.log(d);

Output


false

Steps Description

  1. Declare three variable a, c and d
  2. Initialize three variable with value of array function a(b) { return b < 18;}, c = [44, 23, 37, 60, 75] and d = c.some(a)
  3. Array some() method returns true if the statement given in the array is related to a single element of the array, otherwise it returns false.
  4. The value of b variable is displayed with the help of console.log inbuilt function