$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #207

What is the output?

console.log([1, 2, 3].indexOf('2'));
  1. 1
  2. 2
  3. undefined
  4. -1
indexOf uses strict equality, so the string '2' never matches the number 2.
Play Problem Solving ▸