<html>
<body>
<p>Click the button to display the position of the element "Apple":</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var a = fruits.indexOf("Apple");
document.getElementById("demo").innerHTML = a;
}
</script>
<p><b>Note:</b> The indexOf method was introduced in JavaScript 1.6, and does not work in Internet Explorer 8 and earlier versions.</p>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_indexof_array by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:01:55 GMT -->
</html>