Saturday, March 24, 2012

Q From MS ajax sample

Why microsoft uses the code:

if ( typeof(Sys)!=="undefined" ) Sys.Application.notifyScriptLoaded() ;

and not

if ( typeof(Sys)!= "undefined" ) Sys.Application.notifyScriptLoaded() ;

Is it the same?

Leeor

=== and !== differ from == and != in that they avoid type coersion.

In this particular case, I'm not sure there's a difference, but in general the "strict equals" (=== and !==) operands are usually what you want.


Sorry but I didnt understand theprincipal difference


It's all about type coercion:

"100" == 100 // returns true, because the types are coerced
"100" === 100 // returns false, because the types have to first match before the comparison is even performed

Does that make sense?


That sounds alot betterWink

Thanks man

No comments:

Post a Comment