๋ถํดํ ๋น์ ES6์์ ์ฌ์ฉํ ์ ์๋ ํํ์์ผ๋ก ๊ฐ์ฒด๋ ๋ฐฐ์ด์ ๊ฐ์ ์ถ์ถํ์ฌ ๋ค๋ฅธ ๋ณ์์ ๋ฐฐ์นํ๋ ๋ฐฉ๋ฒ์ด๋ค.
- ๋ฐฐ์ด ๋ถํดํ ๋น
// ๋ณ์ ํ ๋น.
const foo = ["one", "two", "three"];
const [one, two, three] = foo;
console.log(one); // "one"
console.log(two); // "two"
console.log(three); // "three"
// ๋ณ์ ๊ตํ
let a = 1;
let b = 3;
[a, b] = [b, a];
console.log(a); // 3
console.log(b); // 1
- ๊ฐ์ฒด ๋ถํดํ ๋น
// ๋ณ์ ํ ๋น.
const o = { p: 42, q: true };
const { p, q } = o;
console.log(p); // 42
console.log(q); // true
- CreatedAt 2022.12.04