For Loop
While loop
Do while loop
Apart from this three traditional loop, there two shortcut loop in newer javaScript.
Useful shortcut loop (for of, for in)
For of loop
To loop over an array we can use the for of
loop.
let nums = [2,3,4,5,6,7];
for (const num of nums){
console.log(num);
}
For in loop
To loop over an object, we can use for in
loop
let info = {
name : "rajo",
id : 124,
isAlve : true
};
for (const key in info){
console.log(info[key]);
}
Top comments (0)