const [a, b, ...rest] = [10, 20, 30, 40, 50];
// a = 10;
// b = 20;
// rest = [30, 40, 50];
const {a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40}
// a = 10;
// b = 20;
// rest = {c: 30, d:40};
const
, let
, var
)과 함께 사용하지 않으면 에러가 발생할 수 있다function whois({displayName: displayName, fullName: {firstName: name}}){
console.log(displayName + " is " + name);
}
let user = {
id: 42,
displayName: "jdoe",
fullName: {
firstName: "John",
lastName: "Doe"
}
};
whois(user) // jdoe is John