Hacker News new | ask | show | jobs
by EmielMols 4634 days ago
No. It equates to returning undefined, which is the same as having no return statement at all.
2 comments

Although it obviously isn't quite the same. I wonder what is the test result for no return vs return true
Still faster, check revision 6 http://jsperf.com/always-return-on-jquery-events/6

revision 7 http://jsperf.com/always-return-on-jquery-events/7. Just return vs return true (faster).

But as smilekzs points out revision 3 this might not be about the return statement.

!!undefined === false
right. undefined is falsy, but it's quite different to false (i.e. undefined !== false)
true, but a boolean return value is expected for event listener callbacks.
That's not quite how it works. jQuery checks specifically for false with an === comparison. It doesn't do anything like a !! on the return value to convert it to boolean true or false. It only calls stopPropagation and preventDefault when the return value is false, not just any falsy value.

I posted the jQuery code in a previous comment; take a look at that and you can see how it works.