0

Can someone explain this line of JS to me?

for (var X = void 0; list_name.length > 1;) { 
        XXXXX
        }
if (X):
        XXXX

I noticed that if I invert the two parts of the expression '(var X = void 0)' and 'list_name.length > 1' then the script throws the syntax error ('expected an identifier and saw var').

Is it like 'as long as the list has a length of >1, initialise a variable with the name X and do the loop, if the list is not longer than length 1, move into the if(X) part of the loop?'

Slowat_Kela
  • 1,377
  • 2
  • 22
  • 60

0 Answers0