- 할당
- ex) let x, y;
- x = y = 9;
- x +=y; x %= y; x &= y; x ^= y;
- object
- ex) const u = {id: 1, name: ‘hong’, age: 29};
- let {id, name, addr} = u;
- let {id, …info} = u;
- ({id, name} = u);
- const arr = [1, 2, 3, 4, 5];
- let [a, b, …c] = arr;
- [a, b] = [b, a];
- ex) const u = {id: 1, name: ‘hong’, age: 29};
- ex) let x, y;
- 구조 분해 할당(destructuring)
- Object Destructuring
- const {id, name} = {id:1, name:’Hong’};
- Array / Iterator Destructuring
- const [a, b] = [1, 2];
- Default Value Destructuring
- const {id, name, addr = ‘Seoul’} = {id:1, name:’Hong’, add:’Busan’};
- Arguments Destructuring
- function fn({a, b}) {…}
- fn({a:1, b:2});
- Class Destructuring
- const x = new A(1, 2);
- const {a, b} = x;
- Array To Object Destructuring
- const {’0’:a1, ‘1’:a2} = [1, 2];
- ex) const fn = ({age}) => age;
- ⇒ (화살표)는 return을 품고 있다.
- Object Destructuring
728x90
'JS & TS > JavaScript' 카테고리의 다른 글
[JavaScript] Array (0) | 2024.02.08 |
---|---|
[JavaScript] function (0) | 2024.02.08 |
[JavaScript] scope, 실행 컨텍스트, strict mode (0) | 2024.02.08 |
[JavaScript] 형 변환, Hoisting (0) | 2024.02.08 |
[JavaScript] Javascript란? (0) | 2024.02.08 |