for (var part; parts.length && (part = parts.shift());) {}
I thought a for loop can only be like this:
for (var part = 0; i < that.length; part++) {}
So what does that mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Reading this will probably explain a lot.
The initial expression is run once, before the loop starts.
The condition is checked for truth, and if true, the the final expression is run.
The final expression is run (along with the block of code) repeatedly until the condition is false.
You can put anything in any of these positions.
You can even do
for(;;) { }which is known as the forever loop.You can also do a purely conditional for loop.
for (prop in object)is the most common form of that.