Object Rest Property
A nice little tool to "split" objects into something new.
// it's me
const user = {
id: 1,
email: 'mario@mariobros.com',
firstName: 'Mario',
job: 'plumber',
};
// we want to get the user without its email (privacy!)
const { email, ...userWithoutEmail } = user;
console.log(email); // mario@mariobros.com
console.log(userWithoutEmail); // { id: 1, firstName: 'Mario', job: 'plumber' }
Top comments (0)