News for hackers. Stuff that matters.
Re:Conversions in Javascript by cygx on Monday September 17, 2012 @02:20AM (#4531472)
Damn - too much Perl coding recently, where + is always arithmetic.

However, my point still stands: Why are some operators (and in particular unary minus, which is probably the most commonly used one) so much slower than others?

Re:Conversions in Javascript by some-1 on Monday September 17, 2012 @05:25AM (#4531799)
See the following comment: http://news.ycombinator.com/item?id=4530557

The reason why some of them is so fast is because the constant expression is evaluated to a constant, so instead of doing a conversion in the test, the already converted number is returned.

Use this test instead: http://jsperf.com/parse-number-from-string