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             });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM