Is there a way to use a logical operator for object properties? For example, can I do something like:
var myObj = {};
var prop = myObj.prop || 0;
Where prop gets set to 0 if prop isn't a property of myObj? But here,
var myObj = {};
myObj.prop = 2;
var prop = myObj.prop || 0;
myObj.prop is set to 2 because prop exists in this case.
propset to 0 ifmyObj1) doesn't have a property of its own namedprop, 2) doesn't have a property anywhere in its prototype chain namedpropor 3) has a property namedprop(either in the sense of #1 or #2) but it is falsey?