So I'm trying to use switch case for this but this doesn't seems to be the way.
I'm trying
switch (obj) {
case hasPropertyA:
console.log('hasPropertyA');
break;
case hasPropertyB:
console.log('hasPropertyB');
I was expecting that this does obj.hasPropertyX, and if it receive a true value show the console in any case statement, but not
Anyone have an way to do this? I have many properties do check so I can't just use an if( obj.hasOwnProperty(prop) ) {}, that's why I'm trying switch case statement
switchis only for equality tests, not truthy tests. if you have many properties - store them in an array.