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 myInfo = { | |
name: 'Rabin Gaire', | |
age: 12, | |
address: 'Gulmi, Nepal' | |
}; | |
let updatedInfo = { age: 21, address: 'Kathmandu, Nepal', ...myInfo}; | |
console.log(updatedInfo); | |
console.log(myInfo); |
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 myInfo = { | |
name: 'Rabin Gaire', | |
age: 12, | |
address: 'Gulmi, Nepal' | |
}; | |
let updatedInfo = Object.assign({}, myInfo); | |
updatedInfo.age = 21; | |
updatedInfo.address = 'Kathmandu Nepal'; |
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 myInfo = { | |
name: 'Rabin Gaire', | |
age: 12, | |
address: 'Gulmi, Nepal' | |
}; | |
let updatedInfo = myInfo; | |
updatedInfo.age = 21; | |
updatedInfo.address = 'Kathmandu Nepal'; |
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 myInfo = { | |
name: 'Rabin Gaire', | |
age: 12, | |
address: 'Gulmi, Nepal' | |
}; | |
let updatedInfo = {...myInfo, age: 21, address: 'Kathmandu, Nepal'}; | |
console.log(updatedInfo); // { name: 'Rabin Gaire', age: 21, address: 'Kathmandu, Nepal' } | |
console.log(myInfo); // { name: 'Rabin Gaire', age: 12, address: 'Gulmi, Nepal' } |
NewerOlder