JavaScript 2.0
Core Language
Concepts
previousupnext

Thursday, November 11, 1999

Types

The words type and class are used interchangeably in this specification. A type represents a possibly infinite set of values. A value can be a member of multiple such sets, so a value can have more than one type. A value may not have an intrinsic most specific type -- one can ask whether the value v is a member of a given type t, but this does not prevent the value v from also being a member of some unrelated type s. For example, null is a member of type Array as well as type Function, but neither Array nor Function is a subtype of the other.

On the other hand, a variable does have a particular type. If one declares a variable x of type Array, then whatever value is held in x is guaranteed to have type Array, and one can assign any value of type Array to x.


Waldemar Horwat
Last modified Thursday, November 11, 1999
previousupnext