Klucz enumeracji po wartości w TypeScript
W enumeracjach można po nazwie elementu uzyskać jego klucz:
typescriptlet current: number = Season.Winter;
console.log(current); // 0
Задание 1
Opowiedz, jaki będzie wynik wykonania następującego kodu:
typescriptenum Fruits { Apples, Bananas, Oranges, Grapes };
let myFruit: number = Fruits.Apples;
console.log(myFruit);