Simple I have an object that looks like this which is returned directly from a stored procedure in my chrome browser. How can I remove the ones that say null
in javascript/angular 2
?
null
seems to be the only falsy values, so you could do just
arr = arr.filter(Boolean);
If it's just an object with keys, you could do
var obj = {c1 : 's', c2 : 's', c3 : null, c4 : null};
Object.entries(obj).forEach( o => (o[1] === null ? delete obj[o[0]] : 0));
console.log(obj);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With