JS中使用for-each遍历数组

 1   let array = [1, 3, 6, 8, 9, 0, 5];
 2             /* 
 3             index是数组索引
 4             value代表数组的值
 5             arr是指整个数组
 6             */
 7             array.forEach((value, index, arr) => {
 8                 console.log('数组=' + arr);
 9                 console.log('索引号=' + index, '值=' + value);
10             });

 

posted @ 2020-11-05 20:19  陆豪同学  阅读(1870)  评论(0)    收藏  举报