Giá trị enum theo khóa trong TypeScript
Giá trị trong enum có thể được lấy theo các khóa số, tương tự như các phần tử mảng:
enum Season { Winter, Spring, Summer, Autumn };
let current: string = Season[0];
console.log(current); // 'Winter'
Hãy cho biết kết quả thực thi của đoạn mã sau:
enum Fruits { Apples, Bananas, Oranges, Grapes };
let myFruit: string = Fruits[2];
console.log(myFruit);