
const로 선언한 배열에 push, pop이 가능한 이유가 뭘까?

·
TIL
"const로 선언한 변수는 재할당 할 수 없다." 라는 것을 우리는 알고있다.그렇다면 "const로 선언한 배열에 push와 pop이 불가능 해야 하는거 아니냐!" 할 수 있는데이거는 "변수 타입"과 연관이 있다. JS에는 두 가지의 변수 타입이 있다."Primitive Type"과 "Reference Type"이다. Primitive Type은 우리가 익히 알고 있는 string, number, boolean, null, undefined, symbol, bigint이다.이 Primitive Type은 변수에 할당될 때 값을 할당한다.const a = 3;이렇게 변수를 선언하면이런식으로 a는 값 3을 직접 참조한다.a = 2; // Cannot assign to 'a' because it is a c..