jquery - JavaScript filter object when property is true -


i have array of objects , i'm trying filter , return objects in 'issubstitute' property has value true.

    [        {          endtime: "16:00",          issubstitute: false,          outletid: 619777,          starttime: "05:00",          visitdate: "2014-05-30",          id: "168de242-d031-49f2-96d1-803154d0df1e"        },        {          endtime: "17:00",          issubstitute: true,          outletid: 619755,          starttime: "05:00",          visitdate: "2014-05-30",          id: "168de242-d031-49f2-96d1-803154d0dabc"           },        {          endtime: "18:00",          issubstitute: true,          outletid: 619722,          starttime: "05:00",          visitdate: "2014-05-30",          id: "168de242-d031-49f2-96d1-803154d0ddfg"           }        // , on...     ] 

i've tried no luck:

data = $.grep(data, function (e) {        return e.issubstitute = false; }); 

any help, please!

thanks in advance

you use = sets value not checks equality.

use ===, means strictly equal to:

data = $.grep(data, function (e) {     // --------------------v     return e.issubstitute === true;      // or return e.issubstitute; }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -