Array-6

 

In this example, declare an array person = [] and assign the values in arrays: var person = []; person[0] = "Michael"; person[1] = "Voughan"; person[2] = 50; document.getElementById("sample").innerHTML = person[1] + " " + person.length; 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 person = []; person[0] = "Michael"; person[1] = "Voughan"; person[2] = 50; document.getElementById("sample").innerHTML = person[1] + " " + person.length; </script> </body> </html>
Output