Object Deconstruction with Property Aliases

node v6.17.1
version: 1.0.0
endpointsharetweet
function getPeople() { return { firstName: 'Esther', lastName: 'Lee' }; } let { firstName: fName, lastName: lName } = getPeople(); console.log('firstName: ' + fName); console.log('lastName: ' + lName);
WIth the above I can deconstruct the object returned from getPeople() into two variables. I can also rename the variables with an alias so instead of having to use the property names given (firstName, lastName) I can assign the values to names of my own choosing.
Loading…

no comments

    sign in to comment