Created
November 2, 2019 13:46
-
-
Save AkashRajvanshi/2f695bd24956daf23c79668d0c88ee42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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