SMALL
이전 글 (원시타입) : https://jini-dev.tistory.com/66
JS : 데이터 타입 (원시타입 : Boolean, undefined, null, Symbol)
이전 글 : https://jini-dev.tistory.com/65 변수에 값을 할당할 때 그 값의 타입에 따라 자동으로 타입이 결정된다. 타입을 확인" data-og-host="jini-dev.tistory.com" data-og-source-url="https://jini-dev.tistory.com/65" data-og-
jini-dev.tistory.com
객체 타입 : Object Type
여러 속성들의 집합을 나타내며 여러 값들을 저장할 수 있다.
값이 아닌 참조 값( 실제 값(데이터)이 저장되어 있는 위치(메모리)의 주소 )을 저장한다.
-> const 로 선언한 원시타입은 값 변경이 불가하지만, 객체(참조) 타입은 값 변경이 가능하다.
1. Array (배열)
값을 리스트로 나열 할 수 있는 타입
Index
0부터 시작하며 요소에 접근할 수 있다.
const colorArray = ["빨강", "오렌지", "노랑"];
console.log(colorArray); // [ '빨강', '오렌지', '노랑' ]
console.log(colorArray[0]); // 빨강
2. Object (객체)
key(키) : value(값) 의 쌍으로 저장된 타입
객체 속성 접근 방법
1. 대괄호 표기법 : 객체명['속성명']
key 값을 ' ' 로 감싸준다
2. 점 표기법 : 객체명.속성명
- 키 이름이 변수명 작성 규칙을 만족하지 못하는 경우 반드시 대괄호 표기법으로 접근한다. (점 표기법 사용 불가)
- 키 이름이 없는데 접근하는 경우 undefined를 출력한다.
const dictionary = {
red: "빨강",
orange: "오렌지",
yellow: "노랑",
};
console.log(dictionary); // { red: '빨강', orange: '오렌지', yellow: '노랑' }
console.log(dictionary["red"]); // 빨강
console.log(dictionary.red); // 빨강
LIST
'🤍Dev : FE > JavaScript' 카테고리의 다른 글
Node.js란? Node.js 설치 방법 (+VSC) (0) | 2025.05.08 |
---|---|
JS : 호이스팅이란? (+ 스코프) (0) | 2025.05.08 |
JS : 데이터 타입 (원시타입 : Boolean, undefined, null, Symbol) (1) | 2025.05.08 |
JS : 데이터 타입 (원시타입 : Number, String) + (정적타입언어 vs 동적타입언어) (1) | 2025.05.08 |
JS : 변수 선언하기 (변수명 규칙, 변수명 작성 관습) (1) | 2025.05.08 |