I am wondering if JavaScript has an enhanced for loop syntax that allows you to iterate over arrays. For example, in Java, you can simply do the following:
String[] array = hello there my friend.split( );
for (String s : array){
System.out.println(s);
}
output is:
hello
there
my
friend
Is there a way to do this in JavaScript? Or do I have to use array.length
and use standard for loop syntax as below?
var array = hello there my friend.split( );
for (i=0;i<array.length;i++){
document.write(array[i]);
}