해체 할당

1 개요[ | ]

Destructuring assignment
해체 할당

2 JavaScript[ | ]

JavaScript
Copy
var a, b, c, d, e;
[a, b, c] = [3, 4, 5];
console.log(a + ',' + b + ',' + c);
// 3,4,5

e = {foo: 5, bar: 6, baz: ['Baz', 'Content']};
var arr = [];
({baz: [arr[0], arr[3]], foo: a, bar: b}) = e;
console.log(a + ',' + b + ',' + arr);
// 5,6,Baz,,,Content

[a, b] = [b, a]; // swap
console.log(a + ',' + b);
//  6,5

[a, b, c] = [3, 4, 5]; // permutations
[a, b, c] = [b, c, a];
console.log(a + ',' + b + ',' + c);
// 4,5,3

3 PHP[ | ]

PHP
Copy
list($a, $b) = array(1, 2);

4 같이 보기[ | ]

5 참고[ | ]