HI,

> 1) how much slower is === than == (and similarly !== vs !=) in AS and JS?

In AS I don’t know but in JS in most browsers it’s in general 5-20% faster but 
does vary in what you are comparing.

> I seem to recall that certain types and values did a lot of implicit
> coercions in "==" and "!=“.

Yep and this can cause other issues as well. [1] == and != are often referred 
to as the evil twins. This in particular should give cause for alarm. [2] This 
for instance “ \n\n\n” == 0 is true!

Tools like JSLint and SonarCube encourage === and !== to be used. Most coding 
guidelines also prefer === and !==. [3]

> 2) How much slower and fatter is initializing properties to null?

Given it’s a one off and a comparison is likely to be made several time I would 
assume the cost of setting to null would be a lot lower.

> 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
> "!=“.

There’s a few edge cases that you do need to be concerned i.e. empty and not so 
empty strings that equate to false rather than true.

> 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.

That’s my understanding as well.

Thanks,
Justin

1. 
https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons
 
<https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons>
2. http://dorey.github.io/JavaScript-Equality-Table/ 
<http://dorey.github.io/JavaScript-Equality-Table/>
3. http://javascript.crockford.com/code.html 
<http://javascript.crockford.com/code.html>

Reply via email to