javascript - In nodeJs is there a way to loop through an array without using array size? -
let's have
myarray = ['item1', 'item2']
i tried
for (var item in myarray) {console.log(item)}
it prints 0 1
what wish have item1 item2
is there other syntax works without using
for (var = 0; < myarray.length; i++)
you can use array.foreach
var myarray = ['1','2',3,4] myarray.foreach(function(value){ console.log(value); });
Comments
Post a Comment