해체 할당과 마찬가지로 프로퍼티 이름은 반드시 유효한 식별자여야 하고, 들어오는 객체에 해
당 프로퍼티가 없는 변수는
undefined
를 할당받습니다.
배열 역시 해체할 수 있습니다.
function
getSentence
([
subject
,
verb
,
object
]) {
return
`${
subject
} ${
verb
} ${
object
}`;
}
const
arr
= [ "
I
", "
love
", "
JavaScript
" ];
getSentence
(
arr
); // "
I
love
JavaScript
"
확산 연산자(...)를 써서 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.