What is the output of `[1, 2, 3].includes(2)`?

JavaScript Associate Easy

JavaScript Associate — Easy

What is the output of `[1, 2, 3].includes(2)`?

Key points

  • The `.includes()` method checks if an array includes a certain element.
  • In this case, the array does include the element `2`, so the output is `true`.
  • Remember to use square brackets `[]` to define an array in JavaScript.

Ready to go further?

Related questions