Avatar ·

How to get a list of names (keys) of all enum values in TypeScript?

Hello everyone! I just started learning TypeScript and encountered a problem when working with enums.\n\nI have this enum for order statuses:\n\n```typescript\nenum OrderStatus {\n Pending = "PENDING",\n Processing = "PROCESSING",\n Shipped = "SHIPPED",\n Delivered = "DELIVERED",\n Cancelled = "CANCELLED"\n}\n```\n\nI need to display a list of all statuses in a dropdown (select) in the admin interface. I tried using `Object.keys()` and `Object.values()`, but got strange results.\n\nWhen I write:\n\n```typescript\nconsole.log(Object.keys(OrderStatus));\n```\n\nThe console outputs: `["1", "2", "3", "4", "5", "Pending", "Processing", "Shipped", "Delivered", "Cancelled"]`\n\nWhy are there numbers appearing? I expected to see only the names: `["P