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.
Related Posts
The basic purpose of the toLocaleString() is to _________
Identify the process done in the following JavaScript code snippet?
o = {x:1, y:{z:[false,null,””]}};
s = JSON.stringify(o);
p = JSON.parse(s);The purpose of extensible attribute is to __________
What is the prototype represents in the following JavaScript code snippet?
function f() {};To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the ____________
In the following syntax, the data type within the square brackets must be ___________
book[datatype]=assignment_value;A linkage of series of prototype objects is called as ________
Join The Discussion