-
Consider the following code snippet.
for(var n in m)
console.log(m[n]);
The above code is equivalent to which code?
-
-
for (var i = 1;i < a.length;i++)
console.log(a[i]);
-
for (var i = 0;i < a.length;i++)
console.log(a[i]);
-
for (int i = 0;i < a.length;i++)
console.log(a[i]);
-
for (var i = 0;i <= a.length;i++)
console.log(a[i]);
- None of these
-
Correct Option: B
The in variable does the same task of traversing the array starting from the 0 index. The for/in loop makes it easy to do the same that we do using a for.