Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 16, 2023 16:30
Show Gist options
  • Save suhailgupta03/2fc20b593c57ee70d113e1215d025536 to your computer and use it in GitHub Desktop.
Save suhailgupta03/2fc20b593c57ee70d113e1215d025536 to your computer and use it in GitHub Desktop.
let employee = {
name: 'John',
age: 30,
salary: 1000
}
const {name, ...others} = employee;
// ...others means that all the other
// properties of the object will be
// stored in the others variable
// except the name property
// because we have already stored it in
// the name variable
// ...others is called the rest operator
console.log(others);
const list = [1,2,3,4,5];
const [first, two, ...otherNumbers] = list;
console.log(otherNumbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment