사전지식
- 데이터 타입에는 기본형(Primitive)과 참조형(References=Non-Primitive)이 있습니다.
- JavaScript는 object를 제외한 모든 것이 Primitive한 성격을 가지고 있습니다.
- Primitive type : 데이터의 실제 값을 할당합니다.
- Reference type : 데이터의 위치 값을 할당합니다.
Primitives Type
- data가 변수에 저장될 때, 고정된 크기(Byte)로 저장됩니다.
- 변수 선언, 초기화, 할당 시 메모리 영역에 직접 접근합니다.
- 종류는 string, number, boolean, null, undefined, symbol, bigint가 있습니다.
const foo = 1;
let bar = foo;
bar = 9;
console.log(foo, bar);
▽ 1.1 기본형은 그 값을 직접 조작한다.
//결과
1, 9
Reference Type (Complex)
- data의 크기가 정해져 있지 않고, 변수에 할당될 때 데이터에 대한 참조만 저장됩니다.
- 종류로는 object, array, function이 있습니다.
▽ 1.2 참조형(Complex)는 참조를 통해 값을 조작한다.
const foo = [1, 2];
const bar = foo;
bar[0] = 9;
console.log(foo(0), bar[0]);
//결과
9, 9
naver github STYLE_GUIDE.md
'etc > Conventions' 카테고리의 다른 글
#05. [Naver Conventions 전격해부] Destructuring (1) | 2023.01.01 |
---|---|
#04. [Naver Conventions 전격해부] Arrays (0) | 2022.12.12 |
#03. [Naver Conventions 전격해부] Objects (0) | 2022.12.11 |
#02. [Naver Conventions 전격해부] References (2) | 2022.12.10 |
[코딩 컨벤션] 자바스크립트 스타일 가이드 (NAVER) (0) | 2022.10.25 |