Home
Run >
<DOCTYPE html> <html> <head> <script type="text/javascript"> // Create an array. var arr = ["abc", "def", "ghi", "jkl", "mno", "pqr", "def"]; // Find the first location of "def". document.write(arr.indexOf("def") + "</br>"); // Find "def" starting at index 2. document.write(arr.indexOf("def", 4) + "</br>"); // Find "xyz" (which is not found). document.write (arr.indexOf("xyz")+ "</br>"); </script> </head> <body> </body> </html>