Timeline for Optimizing a JavaScript snippet for portability and readability
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 16, 2012 at 14:55 | comment | added | Ryan Miller | Yes +x is faster, but be careful as it will not have the same results as parseInt(x, 10) if x is not a number. If x = '10px', parseInt(x, 10) will return 10 where +x will return NaN. | |
Jul 16, 2012 at 13:48 | comment | added | JefClaes | If you're not a js regular, it might not be very explicit, not to say plain obscure. But hey, learn the good parts, right? | |
Jul 16, 2012 at 13:10 | comment | added | Florian Margaine | Is it more readable, though? (rhetorical question) | |
Jul 16, 2012 at 13:04 | comment | added | Bill Barry |
Use +x instead of parseInt(x,10) . It is faster, shorter and doesn't lose any conveyed meaning.
|
|
Jul 16, 2012 at 13:03 | history | edited | Florian Margaine | CC BY-SA 3.0 |
edited body
|
Jul 16, 2012 at 12:57 | comment | added | JefClaes | How could I forget the second parseInt argument! | |
Jul 16, 2012 at 12:40 | history | answered | Florian Margaine | CC BY-SA 3.0 |