javascript - Make an object falsy -
this question has answer here:
- change truthy/falsey value of javascript object 3 answers
- force object evaluate false 1 answer
is possible override on object in javascript appears 'falsy'?
for exampe, create object this:
function busystate{ var self = this; self.isset = false; self.enter = function () { self.isset = true; }; self.exit = function () { self.isset = false; }; }; var isloading = new busystate(); isloading.enter(); i can check busy this:
if (isloading.isset) { } but i'd able write shorthand:
if (isloading) { } can object have appear truthy or falsy depending on value of isset?
as far know can't done. if read ecmascript-specification you'll see if(isloading) evaluated if(toboolean(isloading) === true) , toboolean() return true object (as can see in table in specification).
Comments
Post a Comment