Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum 타입 사용을 지양해야 하는 이유에 대해 설명해주세요. #40

Open
youzysu opened this issue Nov 30, 2023 · 1 comment
Assignees

Comments

@youzysu
Copy link
Owner

youzysu commented Nov 30, 2023

대안

  1. as const
  2. const enum
@youzysu
Copy link
Owner Author

youzysu commented Dec 3, 2023

enum A1 {
    UP,
    DOWN,
    LEFT,
    RIGHT
}

const A2 = {
    UP: 1, 
    DOWN: 2, 
    LEFT: 3, 
    RIGHT: 4
} as const

enum B1 {
    UP = "up",
    DOWN = "down",
    LEFT = "left",
    RIGHT = 'right'
}

const B2 = {
    UP: "up", 
    DOWN: "down", 
    LEFT: "left", 
    RIGHT: "right"
} as const
"use strict";
var A1;
(function (A1) {
    A1[A1["UP"] = 0] = "UP";
    A1[A1["DOWN"] = 1] = "DOWN";
    A1[A1["LEFT"] = 2] = "LEFT";
    A1[A1["RIGHT"] = 3] = "RIGHT";
})(A1 || (A1 = {}));

const A2 = {
    UP: 1,
    DOWN: 2,
    LEFT: 3,
    RIGHT: 4
};

var B1;
(function (B1) {
    B1["UP"] = "up";
    B1["DOWN"] = "down";
    B1["LEFT"] = "left";
    B1["RIGHT"] = "right";
})(B1 || (B1 = {}));

const B2 = {
    UP: "up",
    DOWN: "down",
    LEFT: "left",
    RIGHT: "right"
};

관련 질문

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant