안녕하세요, 피터팬입니다!
오늘은 JS의 Computed property에 대해 배워볼건데요.
computed property를 직역하면 계산된 프로퍼티입니다.
computed property는 객체의 key값을 표현식(변수, 함수 등)을 통해 지정하는 문법입니다.
사용법
let a = "apple";
let b = {
[a] : 12345;
}
예시
const appleId = "1534";
const carrotId = "3534";
const fruitList = {
[appleId]: "Good",
[carrotId]: "Bad"
};
console.log(fruitList[appleId]);
Reference
'WebProgramming > JS' 카테고리의 다른 글
[JavaScript] 한 페이지 정리 (0) | 2022.07.26 |
---|---|
[JavaScript] Object Methods(assign,keys,values,entries,fromEntries) (0) | 2022.07.26 |
[JS] Array 메소드 (map,filter,reduce,find,concat,slice) (0) | 2022.07.15 |
[JS] JS 라이브러리 (lodash, axios) (0) | 2022.06.30 |
[TS] 타입 별칭 & Interface (0) | 2022.06.24 |
[TS] TS의 타입 시스템? & Compliation Context (0) | 2022.06.12 |
[TS] TypeSCript이란? & 타입 (0) | 2022.06.12 |
[JS] JSON (0) | 2022.06.11 |
안녕하세요, 피터팬입니다!
오늘은 JS의 Computed property에 대해 배워볼건데요.
computed property를 직역하면 계산된 프로퍼티입니다.
computed property는 객체의 key값을 표현식(변수, 함수 등)을 통해 지정하는 문법입니다.
사용법
let a = "apple";
let b = {
[a] : 12345;
}
예시
const appleId = "1534";
const carrotId = "3534";
const fruitList = {
[appleId]: "Good",
[carrotId]: "Bad"
};
console.log(fruitList[appleId]);
Reference
'WebProgramming > JS' 카테고리의 다른 글
[JavaScript] 한 페이지 정리 (0) | 2022.07.26 |
---|---|
[JavaScript] Object Methods(assign,keys,values,entries,fromEntries) (0) | 2022.07.26 |
[JS] Array 메소드 (map,filter,reduce,find,concat,slice) (0) | 2022.07.15 |
[JS] JS 라이브러리 (lodash, axios) (0) | 2022.06.30 |
[TS] 타입 별칭 & Interface (0) | 2022.06.24 |
[TS] TS의 타입 시스템? & Compliation Context (0) | 2022.06.12 |
[TS] TypeSCript이란? & 타입 (0) | 2022.06.12 |
[JS] JSON (0) | 2022.06.11 |