In Java, there's the same for syntax at the bottom.
String[] myStringArray = {"Hello","World"};
for(String s : myStringArray)
{
//Do something
}
Is this not available in JavaScript?
array for-loop javascript
Normal
for(var i=0; i<array.length; i++) {
console.log(array[i]);
}
Like this
for(var i in array) {
console.log(array[i]);
}
Although there is this forin format, it does not work properly with IE8, so we recommend that you use the above method.
© 2024 OneMinuteCode. All rights reserved.