October 2017
Intermediate to advanced
280 pages
6h 50m
English
The Enum types are primitive user-defined types that, according to the specification, are subclasses of Number. The concept of enums exists in the Java, C++, and C# languages, and it has the same semantics in TypeScript: user-defined types consisting of sets of named values called elements. In TypeScript, we can define an enum using the following syntax:
enum STATES {
CONNECTING,
CONNECTED,
DISCONNECTING,
WAITING,
DISCONNECTED
};
This will be translated to the following JavaScript:
var STATES; (function (STATES) { STATES[STATES["CONNECTING"] = 0] = "CONNECTING"; STATES[STATES["CONNECTED"] = 1] = "CONNECTED"; STATES[STATES["DISCONNECTING"] = 2] = "DISCONNECTING"; STATES[STATES["WAITING"] = 3] = "WAITING"; STATES[STATES["DISCONNECTED"] ...Read now
Unlock full access