Aliases destructuring ES6 example in JavaScript

Straight to the example of giving another name to destructure literals from the javascript object.

let obj1 = {
a: 'mercy',
b: 'grace',
c: 'blessing'
}

let obj2 = {
a: 'cool',
b: 'awesome',
c: 'rastafaria'
}

//destructuring ES6 way obj1: 
const {a, b, c} = obj1;

//destructuring ES6 way obj2: (Oops same keys error if using obj1 and obj2 in same file, so saviour is aliases aliases aliases!)
const { a: newA, b: newB, c: newC } = obj2;

Thanks for checking here! hope it solves your search and save your time! 

Published by Post Maker

Hello I am post maker for this website.