[TypeScript] enum, const enum, as const
enum, const enum 비교나는 상수를 선언할 때 습관적으로 enum을 사용했었는데, 타입스크립트에서 enum보다는 const enum을 사용하는 게 더 좋다는 글을 보았다. enum ColorType { RED, BLUE, GREEN}console.log(ColorType.RED); // 0const enum ColorType { RED, BLUE, GREEN}console.log(ColorType.RED); // 0 enum의 문제는런타임에 객체를 만들기 때문에 오버헤드가 발생한다.사용되지 않는 코드들도 번들에 포함되어 번들 용량이 증가한다. (즉, Tree Shaking이 안 된다.) const enum을 사용하면 위의 문제들이 해결되지만, 제한이 있다.리버스 매핑이 안 ..
2025. 2. 10.
[JavaScript/알고리즘] CyclicRotation (feat. 테스트 케이스)
Lesson 2 (Arrays) - CyuclicRotation(Easy) Test results - CodilityAn array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9,app.codility.com점수: 62/100 일단 코딜리티는 문제를 제출하면 코드 수정을 못하더군요.테스트 케이스를 추가하는 능력도 중..
2025. 1. 4.