Skip to content

Instantly share code, notes, and snippets.

@AkashRajvanshi
Created November 2, 2019 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkashRajvanshi/2f695bd24956daf23c79668d0c88ee42 to your computer and use it in GitHub Desktop.
Save AkashRajvanshi/2f695bd24956daf23c79668d0c88ee42 to your computer and use it in GitHub Desktop.
let fullName = {
first: 'Akash',
last: 'Rajvanshi'
};
fullName = {...fullName, age: 22}
console.log(fullName) // { first: 'Akash', last: 'Rajvanshi', age: 22 }
// Extra Features
// 1. Changing content of an object
fullName = {...fullName, age: 25}
console.log(fullName) // { first: 'Akash', last: 'Rajvanshi', age: 25 }
// 2. Copy data of an object :
const copy = {...fullName};
console.log(copy) // { first: 'Akash', last: 'Rajvanshi', age: 25 }
// 3. Defaults Values
const allData = {age: 30, ...fullName} // Remain default for fullName
console.log(allData) // { first: 'Akash', last: 'Rajvanshi', age: 25 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment