According to this : http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9f.html Quote:
An untyped variable is not the same as a variable of type Object. The key difference is that untyped variables can hold the special value undefined , while a variable of type Object cannot hold that value.
However when I test it as :
var objTest:Object = 123;
var untypedTest:* = 123;
objTest = undefined;
untypedTest = undefined;
//This is understandable but why was the assignment even allowed?
trace(objTest); // prints null
trace(untypedTest); // prints undefined
objTest=null;
untypedTest = null;
//This is also understandable ... both can store null
trace(objTest); // prints null
trace(untypedTest); // prints null
//If they are null whey are they being equal to undefined?
if(objTest==undefined)
trace("obj is undefined");
if(untypedTest==undefined)
trace("untyped is undefined");
//Because null is same as undefined!
if(null==undefined)
trace("null is same as undefined?");
Two questions:
- Why is assignment to undefined allowed for obj? (not a big issue since it still prints as null)
- If we compare null with undefined the result true (even if null stored in an Object). What is the point of making a difference between null and undefined if they are equal?
Some samples of that:
Or:
So when you’re assigning
undefinedtoObjectinstance Flash converts it tonullthe same way.Boolean.You can use strict comparison to have
false: