How to use JavaScript Array some()

Array some

On this page

Array some() method

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

  • Declare three variable a, c and d
  • Initialize three variable with value of array function a(b) { return b < 18;}, c = [44, 23, 37, 60, 75] and d = c.some(a)
  • 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.
  • The value of b variable is displayed with the help of console.log inbuilt function