ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 数组的六种遍历方法 1. for循环 2. for in ```js for(var i in arr) { console.log(i); } ``` 3. for of 4. arr.forEach ``` var arr = [1, 2, 3]; arr.forEach((v, k)=>{ console.log(v); console.log(k); }) ``` 5. Array.from(arr, (value, index)=>{}) ``` Array.from(arr, function(value, index){ console.log(value); console.log(index); }) ``` 6. map ``` arr.map((value, index)=>{ console.log(index); }) ```