scrimba
Understanding Typescript In Depth
Typescript Section-1 - Enums in Typescript #09
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Typescript Section-1 - Enums in Typescript #09
AboutCommentsNotes
Typescript Section-1 - Enums in Typescript #09
Expand for more info
index.ts
run
preview
console
enum Weather {
Sunny,
Cloudy,
Rainy,
Snowy
}
let today: Weather = Weather.Cloudy;
let tomorrow: Weather = 200;
console.log("Today value", today); // Today value 1
console.log("Today key", Weather[today]); // Today key Cloudy
enum Weather1 {
Sunny = 100,
Cloudy,
Rainy = 200,
Snowy
}
/*
var Weather;
(function (Weather) {
Weather[Weather["Sunny"] = 0] = "Sunny";
Weather[Weather["Cloudy"] = 1] = "Cloudy";
Weather[Weather["Rainy"] = 2] = "Rainy";
Weather[Weather["Snowy"] = 3] = "Snowy";
})(Weather || (Weather = {}));
var today = Weather.Cloudy;
var tomorrow = 200;
console.log("Today value", today); // Today value Cloud
console.log("Today key", Weather[today]); // Today key undefined

*/
Console
"Hello from JavaScript"
,
index.html
-2:28