+ 2
please explain this condition
for(var x=0;x<arr.length;x++)
6 Réponses
+ 6
Whatever code is within the braces of the for loop signature, it will be ran until the control variable is no longer less than arr.length.
+ 4
for loop executes a code while the condition remains true. the condition is specified in the first set of parenthesis of the for loop. x =0 sets ur variable at zero. .length specifies the amount of variables or objects in an array. if x is 0 and arr has 3 variables or objects in it the code will execute as long as x is smaller than the length of the array. it will do this once for each number of objects that is in the array and will not stop executing until the number executions is greater than the number of length in the array. ++ is an increment telling us that the variable will increase by one each time the code is executed(which just really means that it will execute more than once. if x is incremented by one the next condition is (x=1;x<arr.length) then it increments again (x=2;x<arr.length) until the number of X is equal to or higher than the number of objects in an array. the first two instructions are carried out first, then increments, then it is repeated...
+ 3
arr . lengt is number of var . for exemple
var arr=[a, b, c] then arr. length =3
+ 1
it's still not clear. can anyone explain it a little more easily and depth.
+ 1
yav for loop un neyini aciklayam bacim
+ 1
loop an array from head to the end.Is it a simple explanation?