How to print array?
Wed Feb 08 2023 19:11:26 GMT+0000 (Coordinated Universal Time)
Saved by
@chesterheng
#javascript
let array = [1, 2, 3, 4, 5];
for (let i = 0; i < array.length; i++) {
console.log(array[i]);
}
let j = 0;
while(j < array.length) {
console.log(array[j]);
j++;
}
for(let value of array) {
console.log(value)
}
for(let key in array) {
console.log(array[key])
}
array.forEach(num => console.log(num));
content_copyCOPY
Comments