Array-2

 

In this example, We will see how we can access javaScript array values by index. vehicles[0] will return "Alto". See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <p id="sample"></p> <script> var vehicles= ["Alto", "Mahindra", "Audi"]; document.getElementById("sample").innerHTML = vehicles[0]; </script> </body> </html>
Output