JS Array index


Array indexOf()

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay", "Aman", "Rehman", "Aman", "Rahul"];
    document.write(a + "<br><br>");
    var b = a.indexOf("Aman",2);
    document.write(b);
  </script>
</head>
<body>
</body>
</html>


Array lastIndexOf()

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay", "Aman", "Rehman", "Aman", "Rahul"];
    document.write(a + "<br><br>");
    var c = a.lastIndexOf("Aman");
    document.write(c + "<br><br>");
  </script>
</head>
<body>
</body>
</html>