Common JavaScript Manual/Do .. While and For .. in loops

Do .. WhileEdit

In this cycle, executing the code in it and then check the condition and if it is true then the loop is executed again, otherwise terminate the loop. Let's see example.

names = ["JavaScript","Python","Ruby"];
i = 0;
  name = names[i];
}while(print(name) || i < names.length);

Do .. while loop can be used if code inside a loop set some values and in condition you call some function.

For .. inEdit

For .. in loop using if need iterate over all properties of object. For example.

obj = {name:"Artem",
for(i in obj){
  print(i + ':' + obj[i] + '\n')

In this code on every iteration to variable 'i' set value with key of property.

While and For loops · Break, continue, labels