[JavaScript]分割代入備忘録

const d = {
    firstName : 'John',
    lastName  : 'Smith'
};
const t = `I'm ${d.firstName} ${d.lastName}.`;

const {firstName,lastName} = d;
const {firstName:namae,lastName:myoji} = d;

const d = {
    lastName  : 'Smith'
};
const {firstName = 'Jeff',lastName} = d;
const t = `I'm ${firstName} ${lastName}.`;

const d = ['John','Smith'];
const [firstName,lastName] = d;
const t = `I'm ${firstName} ${lastName}.`;