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

 

posted @ 2021-02-28 14:23  AngDH  阅读(52)  评论(0编辑  收藏  举报