8 ms·
No. It equates to returning undefined, which is the same as having no return statement at all.
by EmielMols 13y ago
No. It equates to returning undefined, which is the same as having no return statement at all.
- dreen 13y agoAlthough it obviously isn't quite the same. I wonder what is the test result for no return vs return true
- Tarang 13y agoStill faster, check revision 6 http://jsperf.com/always-return-on-jquery-events/6 http://jsperf.com/always-return-on-jquery-events/6 revision 7 http://jsperf.com/always-return-on-jquery-events/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.
- lucideer 13y ago!!undefined === false
- bengillies 13y agoright. undefined is falsy, but it's quite different to false (i.e. undefined !== false)
- lucideer 13y agotrue, but a boolean return value is expected for event listener callbacks.
- Stratoscope 13y agoThat'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.