Hi,
> undefined can be a functional change to ActionScript code when adding to
> numbers and strings:
>
> var obj:Foo;
> trace(1 + undefined); NaN
> trace("hello " + undefined); //hello undefined
> trace(1 + obj); //1
> trace("hello " + obj); //hello null
> trace(1 + null); //1
> trace("hello " + null); //hello null
So currently that produces a different result when cross compiled to JS.
NaN
hello undefined
NaN
hello undefined
1
hello null
Wouldn’t you consider that a bug? How often would this occur in the real world
and would it matter I’m not 100% sure.
> However, I'm actually not sure that initializing Numbers is necessary.
> Leaving it as undefined is generally functionally equivalent to NaN:
>
> isNaN(undefined) //true
> isNaN(null) //false
It increased performance by around 5% in our applciation so in my books that’s
reason enough to do it
> But initializing ints to null will generally get the same result as
> initializing them to 0…
Currently int's are initialised to 0 no one has suggested setting them to null.
Thanks,
Justin