in JavaScript by

Which one of the given code will be equivalent for the following JavaScript code:

for(var p in o)  


a) Code A

for (var i = 1;i<a.length;i++)  


b) Code B

for (var i = 0;i<a.length;i++)  


C) Code C

for (int i = 0;i<a.length;i++)  


d) Code D

for (var i = 0;i<= a.length;i++)  


1 Answer

0 votes

Answer: A

Reason: The variable in the code A working same ( e.g. traversing the array from the 0 index value) just like it working in the above code. In addition, we can also use the "For-in" loop statement for performing the same task more efficiently.

Related questions

0 votes
asked Mar 22, 2021 in JavaScript by Robindeniel
0 votes
asked Mar 23, 2021 in JavaScript by sharadyadav1986
0 votes
asked Mar 21, 2021 in JavaScript by rajeshsharma