Kode JavaScript untuk mengulangi array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Grepper
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
var arr = ["f", "o", "o", "b", "a", "r"];
for(var i in arr){
console.log(arr[i]);
}
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(function(value, index, array) {
txt = txt + value + "<br>";
});
String[] fruits = {"apple", "orange", "pear"};
for(int i=0; i<fruits.length; i++)
{
System.out.println(fruits[i]);
}
String[] myStringArray = {"Hello", "World"};
for (String s : myStringArray) {
// Do something
}