flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: I just learned something in Javascript
Date Mon, 02 Jan 2017 17:13:00 GMT
Interesting.  Does it work everywhere?

var foo = 20 + Number("1234");

Would that compile to the following and still work?

var foo = 20 + +"1234";


On 1/2/17, 3:08 AM, "Harbs" <harbs.lists@gmail.com> wrote:

>Apparently Number(“1234”) is the same as a shorthand version: +”1234”.
>Both of these will convert a string into a number and will give NaN if
>the string can not be converted to a logical number.
>Performance-wise, different browsers seem to give different results as to
>which one is faster.
>I think we should make it standard practice to use “+” instead of
>Number() for casting to Number in FlexJS. It will save 7 characters for
>every cast.

View raw message