Which loop in JavaScript is suitable when the number of iterations is unknown?
Which loop in JavaScript is used to iterate over the properties of an object?
What is the key difference between a for loop and a for...in loop?
Which loop in JavaScript is used to iterate over the elements of an array?
What will be the output of the following code?
let i = 1;
while (i <= 5) {
console.log(i);
i++;
}
What will be the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let key in obj) {
console.log(key);
}
What will be the output of the following code?
let arr = [1, 2, 3, 4, 5];
for (let element of arr) {
console.log(element);
}
What will be the output of the following code?
let i = 5;
do {
console.log(i);
i--;
} while (i >= 1);
What will be the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let value of obj) {
console.log(value);
}
Which loop is more suitable for iterating over the values of an iterable object like an array?
Which loop is used to iterate over the characters of a string?
What is the output of the following code?
let obj = { a: 1, b: 2, c: 3 };
for (let key in obj) {
console.log(obj[key]);
}
What will be the value of 'i' after the execution of the following code?
let i = 0;
for (; i < 5; i++) {}
What will be the output of the following code?
let arr = [1, 2, 3, 4, 5];
for (let element of arr) {
if (element === 3) {
break;
}
console.log(element);
}
51 videos|30 docs|12 tests
|