What is the output of: [1, 2, 3].indexOf(4)?

JavaScript Associate Easy

JavaScript Associate — Easy

What is the output of: [1, 2, 3].indexOf(4)?

Key points

  • `indexOf` returns the index of the first occurrence
  • -1 signifies the value is not in the array
  • The method searches from the start of the array
  • It returns the index, not the value itself

Ready to go further?

Related questions