I can add more arrays even if I mention the number of arrays in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I can add more arrays even if I mention the number of arrays in my code

var courses = new Array(3); courses[0] = "HTML"; courses[1] = "CSS"; courses[2] = "JS"; courses[3] = "Swift"; courses[4] = "Java"; document.write(courses[4]); My output is: Java Why? It should not store more than 3 arrays.

24th Dec 2016, 4:02 AM
Arun MV
Arun MV - avatar
2 Answers
+ 1
Because declaring an array does not require you to state what is the length of the array. Declaring an array is simply var courses = []
24th Dec 2016, 4:10 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 1
YES U CAN ARUN. .pls follow me ARUN MV
24th Dec 2016, 4:39 AM
MEDHIR
MEDHIR - avatar