var arr = ["Brother Tao" , "Male" , 24, "College" , "University of Science and Technology Beijing" ];
for(var i=0;i<5;i ){
document .write(arr[i] "<br/>");
Every array element in variable arr does not meet the condition of i<5, why is it output?
i represents the index value, which is arr[0], arr[1]...arr[5]. The 12345 in the square brackets is equivalent to i, which means which element!
The subscript of the array starts from 0, and the subscript of the University of Science and Technology Beijing is exactly 4, meeting the condition of less than 5
i<5 is the condition of the for loop. Specify five loops. This has nothing to do with variables
are all satisfied! ! !
Did you not understand the meaning of the pointer?
arr = ["Brother Tao", "Male", 24, "College", "University of Science and Technology Beijing"];
arr If the pointer is not set, it starts from 0 by default.
arr[0] is equal to "Brother Tao" arr[4] is equal to "University of Science and Technology Beijing"
My foundation is very important. Take a look at the js manual