On Jan 2, 2017, at 7:34 PM, Alex Harui <aha...@adobe.com> wrote: > Where can I read more about this syntax?
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus_() > Does the difference really move the needle? Does GCC optimizer replace > Number with a shortened name anyway? IFAIK, GCC leaves Number() as is. I just searched a current minimized project and there were 137 Number() casts. That would be a savings of 959 bytes. The entire minimized file is 402 KB. We’d possibly have an extra space before the unary plus, but even so, it would be a savings of 822 bytes. > What if you take away all whitespace? I think it depends on where. 20 + +”1234” works, while 20++”1234” fails miserably with the following error: Uncaught ReferenceError: Invalid left-hand side expression in postfix operation var foo=+”1234”; works fine. > What should we generate for: > > var bar = "1234"; > var foo = Number(bar); > var bar = "1234"; var foo = +bar; > var foo = Number("12" + "34”); Good question. +("12" + "34") probably makes the most sense for this case. > Sorry for all of the questions. I'm trying to understand how much gain we > get for how much work. > > Thanks, > -Alex > > On 1/2/17, 9:23 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> Or more concisely: >> >> console.log(20 + +"1234") >> < 1254 >> >> On Jan 2, 2017, at 7:21 PM, Harbs <harbs.li...@gmail.com> wrote: >> >>> Apparently, yes: >>> >>>> var foo = 20 + +"1234"; >>> < undefined >>>> foo >>> < 1254 >>> >>> On Jan 2, 2017, at 7:13 PM, Alex Harui <aha...@adobe.com> wrote: >>> >>>> var foo = 20 + +"1234"; >>> >> >