Prev Demo
Array Indexof() Method
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <p>Click the below button to know the position of India, when the start position is 3.</p> <button onclick="myFunction()">Find</button> <p id="myId"></p> <script> function myFunction() { var a = ["France", "India", "Darziling", "China", "Bangladesh", "India", "Abudhabi"]; var b = a.indexOf("India", 3); document.getElementById("myId").innerHTML = b; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output