Thursday 20 July 2017

Best way to delete undefined values from an object

Hi!I need a way to delete undefined fields from an object.What is the best way in terms of efficiency?I found this trick to do that, but I am wondering if there is a better way:var person = { 'first_name': 'John', 'last_name': 'Johnson', 'address': undefined, 'job': null, } person = JSON.parse(JSON.stringify(person)); // <- what i'm using now => { first_name: 'John', last_name: 'Johnson', job: null } Thanks!

Submitted July 20, 2017 at 02:55PM by honestserpent

No comments:

Post a Comment