Javascript 如何按数组的值删除数组中的对象?

Javascript 如何按数组的值删除数组中的对象?,javascript,node.js,Javascript,Node.js,我正在使用Node.js,这是我对路由的响应 我想删除值为“existence”:false的对象,并输出值为“existence”:true的对象 这是到目前为止我的代码 schedule.get('/conference/schedule_participants/:circle/:confUid/:schedId', function(req, res) { if(req.schedId){ getParticipants( req.params, function(cont

我正在使用Node.js,这是我对路由的响应

我想删除
值为“existence”:false的对象,并输出值为“existence”:true的对象

这是到目前为止我的代码

schedule.get('/conference/schedule_participants/:circle/:confUid/:schedId', function(req, res) {
  if(req.schedId){
    getParticipants( req.params, function(contacts){
      results.contacts=contacts;
      res.send('response('+JSON.stringify(results.contacts)+')');
    }); 
  } else{
      res.send('response('+JSON.stringify(results.contacts)+')');
  }
});
使用

使用

使用

使用

您可以使用:

您可以使用:

您可以使用:

您可以使用:


您好@Buzinas。我想删除值为
“existence”:false“
的对象,并输出值为
“existence”:true的对象“
@Agent69这正是我在这里要做的;)如果您不喜欢可读性,可以将
过滤器
return更改为
return c.existence==true。但既然它已经是一个布尔值,就完全没有必要这样做。我想删除值为
“existence”:false“
”的对象,并输出值为
“existence”:true“
@Agent69”的对象,这正是我在这里要做的;)如果您不喜欢可读性,可以将
过滤器
return更改为
return c.existence==true。但既然它已经是一个布尔值,就完全没有必要这样做。我想删除值为
“existence”:false“
”的对象,并输出值为
“existence”:true“
@Agent69”的对象,这正是我在这里要做的;)如果您不喜欢可读性,可以将
过滤器
return更改为
return c.existence==true。但既然它已经是一个布尔值,就完全没有必要这样做。我想删除值为
“existence”:false“
”的对象,并输出值为
“existence”:true“
@Agent69”的对象,这正是我在这里要做的;)如果您不喜欢可读性,可以将
过滤器
return更改为
return c.existence==true。但既然它已经是一个布尔值,就完全没有必要这样做。
var filtered = results.contacts.filter(function(contact) {
    return contact.existence;
});
var filtered = results.contacts.filter(function(c) {
  return c.existence;
});

res.send('response(' +JSON.stringify(filtered) + ')');