search

Home  >  Q&A  >  body text

I don't understand, please give me guidance.

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?

自律者自由自律者自由2616 days ago1321

reply all(4)I'll reply

  • 郭官鹏

    郭官鹏2017-11-15 17:33:48

    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!

    reply
    0
  • 帅帅的阿猪

    帅帅的阿猪2017-10-26 09:38:10

    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

    reply
    0
  • nearest

    nearest2017-10-26 00:07:45

    i<5 is the condition of the for loop. Specify five loops. This has nothing to do with variables

    reply
    1
  • 路过

    路过2017-10-25 08:50:52

    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

    reply
    2
  • Cancelreply