Basically can I do the following…
var obj = {}:
obj.falsey = true;
if(obj){
//code not executed
}else{
//code executed
}
I could take advantage of the fact !,+,~…
Call valueOf/toString and do the following, but I would like to avoid that.
var obj = {valueOf:function(){return 0}}:
obj.falsey = true;
if(!!obj){
//code not executed
}else{
//code executed
}
Why would I want to do this? Because I’m curious 😀
You can borrow a false
Number,Boolean…. from an iframe and extend its prototype.Basically the following doesn’t work because Numbers are a primitive value.
This does, but obviously this pollutes the Number.prototype, so you should really borrow a different
Numberobject from another iframe.Ultimately, just not a very good idea.