Sajeetharan Sajeetharan - 1 month ago 4x
Javascript Question

Quickest way to check which property inside an object holds value?

Probably a dumb question, Assume i have an object like below,


What is the quickest way to check which properties hold the values in the above object without using a loop?

while doing this inside a for loop is working,

if(typeof someUndefVar == whatever) -- works


Country, Continent and State

var a = {"Country":"country","Continent":"continent","Province":"","District":"","State":"state","City":""};

Object.keys(a).filter( prop => a[prop] );

It also depends on how you want to handle the 0, null, undefined values.