Why this piece of code returns 0
a=!!function(){console.log(!0)}()+!!function(){console.log(!0)}()
and this one returns 2
a=!!function(){}+!!function(){}
Whats the magic behind it?
Edit:
This is what I would expect:
function(){console.log(!0)}()
should return true because it was successful and it contains body. So when it is casted to boolean and then int it should be 1
function(){}
this should be false, since it is neither called nor contains function body. Same confusion with !![]
and !!""