I was reading through this SO question. I sort of understand what's going on, but I'm confused why
!function foo() {
console.log(true) ;
}()
doesn't return false
.
!function () {}()
This will also return the boolean opposite of the return value of the function, in this case true, because !undefined is true. If you want the actual return value to be the result of the call, then try doing it this way:
"will also return the boolean opposite" makes me think that false
should be returned. Why isn't it. alert(!true); //false