Value Types and Reference Types
2023. 7. 14. 11:04ㆍ자바스크립트 정리
728x90
반응형
value Types : String , number, boolaan, NaN , undefined, Null
let a = 50;
let b = a;
a = 10; // a에 10을 다시 참조 했지만 b에는 영향이 가지 않는다.
console.log(b);
//50
Reference Types : array, object , function
const a = ["1", "2", "3"];
const b = a;
a.push("4");
console.log(b);
//(4) ['1', '2', '3', '4']
// 값을 복사 하는것이 아니라 레퍼런싱 하는것이다. 배열은 참조
'자바스크립트 정리' 카테고리의 다른 글
쿠키(Cookie) (0) | 2023.07.17 |
---|---|
정규표현식 (0) | 2023.07.17 |
Primitive Types (0) | 2023.07.14 |
Call Stack (0) | 2023.07.14 |
스코프 (0) | 2023.07.13 |