Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the equivalent code of the following JavaScript code?
for(var p in o)
console.log(o[p]);

What will be the equivalent code of the following JavaScript code?
for(var p in o)
console.log(o[p]);
a) for (var i = 0;i < a.length;i++)
console.log(a[i]);
b) for (int i = 0;i < a.length;i++)
console.log(a[i]);
c) for (var i = 0;i <= a.length;i++)
console.log(a[i]);
d) for (var i = 1;i < a.length;i++)
console.log(a[i]);

Answer: a
Explanation: 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.

Join The Discussion