如何通过其值删除数组中的对象?

时间:2015-10-02 01:43:58

标签: javascript node.js

我正在使用Node.js,这是我对路线的回应。

enter image description here

我希望删除值为#include <iostream> class Point { const double x; const double y; public: Point () = delete; Point ( Point && other ) : x { other.x }, y { other.y } {} explicit Point ( double xx, double yy) : x { xx }, y { yy } {} }; class City : public Point { const std::string name; public: City () = delete; City ( City && other ) : Point ( std::forward < City > ( other ) ) , name {other.name}{} // is other scrapped by the time I try to get the name? explicit City ( double xx, double yy, std::string nname ) : Point ( xx, yy ), name{nname}{} }; int main() { } 的对象,并输出值为&#34;存在&#34;的对象:true&#34;

到目前为止,这是我的代码。

"existence":false

2 个答案:

答案 0 :(得分:2)

您可以使用Array.prototype.filter

var filtered = results.contacts.filter(function(c) {
  return c.existence;
});

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

答案 1 :(得分:1)

使用Array.prototype.filter()

var filtered = results.contacts.filter(function(contact) {
    return contact.existence;
});