Node.js Tutorial - Node.js Loop Statement








JavaScript also supports while , do...while , and for loops.

for...in loop are also supported in Node.js.

Example

The following code shows that we can get the names of all the keys on an object:


var user = {
     first_name: "CSS",
     last_name: "HTML",
     age: 4,/*from   w w  w. java 2 s  .c  o m*/
     website: "java2s.com"
};

for (key in user) {
     console.log(key);
}

The code above generates the following result.