Enea Xharja

Remove a property from an object

Remove a property from an object using the rest operator (ES6):

const user = {
  name: 'Enea',
  age: 99,
  jsMaster: true,
};

const { jsMaster, ...updatedUser } = user;

console.log(updatedUser); // {name: "Enea", age: 99}
console.log(user); // {name: "Enea", age: 99, jsMaster: true}

Updated on January 06, 2021

Tagged with: javascript, snippets


Profile picture

Hey there! I'm Enea, a web developer currently working at eqolot. Welcome to my little corner of the web, where I share my open collection of notes, code snippets, and resources on topics that interest me.

© 2021 Enea Xharja