var arr =[{name:'tom'},{name:'john'},{name:'jim'}];
arr.forEach((item)=>{
if(item.name==="john"){
item={name:'aaa'}
}
});
var arr =[{name:'tom'},{name:'john'},{name:'jim'}];
arr.forEach((item)=>{
if(item.name==="john"){
item={name:'aaa'}
}
});
本文标题:js for循环不能直接改变当前项
本文链接:https://www.haomeiwen.com/subject/kcltxdtx.html
网友评论