Javascript examples for Array:lastIndexOf
Search an array for the item "Apple":
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . j a va 2s .com*/ var fruits = ["Banana","Orange","Apple","Mango","Banana","Orange","Apple","Mango"]; var a = fruits.lastIndexOf("Apple"); var x = document.getElementById("demo"); x.innerHTML = a; } </script> </body> </html>