Modify ↓
Ticket #5299 (closed enhancement: wontfix)
odd & even methods improvements
| Reported by: | dsonet | Owned by: | john |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.4 |
| Component: | selector | Version: | 1.3 |
| Keywords: | division bitwise | Cc: | |
| Blocking: | Blocked by: |
Description
I notice here use % to test if the number is even or odd. I suggest we use bitwise operator here to get the best performance. So, we can rewrite them as:
even: function(elem, i){
return !( i & 1 );
}, odd: function(elem, i){
return ( i & 1 ) === 1;!!(i & 1)
},
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

There is no effective performance difference between these two operations. jsperf test