有没有办法修改_.reject内的原始数组?
我尝试过以下方法:
https://jsfiddle.net/jimmyt1988/LS384/953/
var section = {
rows: [
{name:"Alejandro", $initialized: true},
{name:"Benito", $initialized: false},
{name:"Chinea", $initialized: true},
{name:"Domingo", $initialized: true},
{name:"Eduardo", $initialized: false},
{name:"Yolanda", $initialized: true},
{name:"Zacarias", $initialized: true}
]
};
section.rows = _.reject(section.rows, function(row, index, sectionRows){
if (!row.$initialized) {
return true;
}
else
{
sectionRows[index] = { test: "test" };
return false;
}
});
console.dir(section.rows);