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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -