Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

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

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Do .. While 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; do{ name = names[i]; 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 .. in For .. in loop using if need iterate over all properties of object. For example. obj = {name:"Artem", country:"Russia", interests:"JavaScript"}; for(i in obj){ print(i + ':' + obj[i] + '\n') } In this code on every iteration to variable 'i' set value with key of property. 75% While and For loops Break, continue, labels