js基础 数组forEach
var doc = document.querySelectorAll("li"); doc.forEach(function(item){ todo });
var arr = [ {title:"aaaaa"}, {title:"bbbb"}, {title:"ccccc"} ]; arr.forEach(function(item,index,lessons){ item.title = item.title.substr(0,2); }); console.table(arr);