Reputation: 7294
I would expect an error on this code TypeScript:
var obj:Object;
var num:number;
obj = 4; // no error!
num = 4; // ok
num = obj; // error.
Any good reason for not getting an error?
Upvotes: 2
Views: 478
Reputation: 106640
Object: Provides functionality common to all JavaScript objects.
The Object object is contained in all other JavaScript objects; all of its methods and properties are available in all other objects. - Source
It works the way you described because a number
is an Object
, but an Object
isn't necessarily a number
.
Upvotes: 3