Lấy khóa của enum theo giá trị trong TypeScript

Trong enum, bạn có thể lấy khóa của một phần tử dựa trên tên của nó:

typescriptlet current: number = Season.Winter;
console.log(current); // 0
Задание 1

Hãy cho biết kết quả thực thi của đoạn mã sau:

typescriptenum Fruits { Apples, Bananas, Oranges, Grapes };
let myFruit: number = Fruits.Apples;
console.log(myFruit);