var massiv = [4; 5; 7; 3; 8; 2; 2; 2; 5; 9] 

How to find the position of the first occurrence of the number '2'?

  • 2
    massiv.indexOf(2); Well, in the array, the values ​​separated by commas should be - Rostyslav Kuzmovych
  • promptly) ATP - Redbeard

1 answer 1

Decision:

 massiv.indexOf(2) // вернет index 

More about indexOf can be found on the website: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf