javascript - How to remove undefined and null values from an object using lodash? -


i have javascript object like:

var my_object = { a:undefined, b:2, c:4, d:undefined }; 

how remove undefined properties?

if want remove falsey values compact way is:

_.pick(obj, _.identity); 

for example (lodash 3.x):

_.pick({ a: null, b: 1, c: undefined }, _.identity); >> object {b: 1} 

for lodash 4.x:

_.pickby({ a: null, b: 1, c: undefined }, _.identity); >> object {b: 1} 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -