js中遍歷數組的幾種方法彙總

一、forEach javascript var arr= ['張三', '李四', '王五']; arr.forEach(function(v,k) { console.log(v); //這樣就會分別將name遍歷出來 }); //注意:jquery中each方法是反的,好比: $(arr).each(function(k,v){ console.log(v);
相關文章
相關標籤/搜索