Rahul P Rahul P -4 years ago 97
JSON Question

Removing empty key value pair from an object in javascript

How do i remove an empty key value pair from an object
like

obj = {name: 'asd','':'',pass: true}


is to be made
obj = {name: 'asd',pass: true}


Thanks in advance

Answer Source

Try this delete obj[''];

More about delete operator: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Operators/delete

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download