gpt4 book ai didi

javascript - 删除 underscore.js each() 或其他中的当前对象

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:34 25 4
gpt4 key购买 nike

删除 underscore.js 中的当前对象 each() 或其他 ?

_.each(fools, function(user) {
if (user['great'] === true) {
// delete user from fools object ?
}
});

最佳答案

您可能想使用过滤器 http://underscorejs.org/#filter

fools = _.filter(fools, function(user) {
return !user['great'];
});

或者reject,这只是糖分。

关于javascript - 删除 underscore.js each() 或其他中的当前对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16991556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com