As Josh mentioned in the other thread, we need data. Maybe there isn't a right answer and folks will have to use directives or compiler options to get what they want for their needs.
The data probably needs to answer at least the following questions: 1) how much slower is === than == (and similarly !== vs !=) in AS and JS? I think you'd have to test for different types and maybe values. I don't have time to look for the code, maybe somebody can find it in Tamarin, but I seem to recall that certain types and values did a lot of implicit coercions in "==" and "!=". 2) How much slower and fatter is initializing properties to null? IIRC, in ActionScript, unless you are using "*", all other types cannot have the value undefined, so most code never needed to worry about the difference. The vast majority of regular Flex SDK code just uses "==" and "!=". AIUI, in JavaScript, the same code for types that are not "*" that tests with "==" and "!=" will "just work". If the code uses "===" or "!==" will it be that much faster if we have to stop and initialize EVERY uninitialized property to null? We might be able to be smart and initialize local variables to null if the method body is using "===" but again, is it worth it? For "*", I believe we are emitting ES5 and/or only supporting browsers that run ES5, so I think that means that undefined cannot be redefined and (typeof Foo === 'undefined') isn't necessary. Others should very this. We could also warn on use of '===' and '!==' when null or undefined is involved. My 2 cents, -Alex On 6/2/17, 9:14 PM, "Josh Tynjala" <joshtynj...@gmail.com> wrote: >I just mentioned the same thing in response to your other thread. > >Defaulting to null (where appropriate) would help, I think. However, later >assignments can still cause a variable to be set to undefined in JS but >null in SWF. That could be considered a separate issue, but it's >definitely >related. > >- Josh > >On Jun 2, 2017 6:55 PM, "Justin Mclean" <jus...@classsoftware.com> wrote: > >> Hi, >> >> This code: >> >> private var a:Object; >> >> protected function init():void >> { >> trace(a); >> } >> >> When init() is called with display “null” in when run the FlashPlayer >>and >> display “undefined” when compiled into JS and run in a browser. >> >> How should we fix this? >> >> Thanks, >> Justin