override object accessot javascript -
this question has answer here:
i override accessor of javascript object instead of override should return fixed value.
eg.
var obj = {}; console.log(obj.someproperty) //will print undefined expected value false
if property undefined there no way have return false
default "falsey".
for example:
var obj = {}; if (!obj.someproperty) { console.log("expression falsey"); }
a more explicit way test truthiness use double bang operator:
var obj = {}; console.log(!!obj.someproperty) // print's undefined, evaluates false
but in short, going after not work because in javascript cannot redefine undefined
.
Comments
Post a Comment