[英]Modify the original array inside _.reject
Is there a way to modify the original array inside an _.reject? 有没有办法修改_.reject内部的原始数组?
I've tried the following: 我尝试了以下方法:
https://jsfiddle.net/jimmyt1988/LS384/953/ 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.