javascript - Make an object falsy -


this question has answer here:

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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -