Skip to content

Instantly share code, notes, and snippets.

View rabingaire's full-sized avatar
🇳🇵
Let everything happen

rabin rabingaire

🇳🇵
Let everything happen
View GitHub Profile
let myInfo = {
name: 'Rabin Gaire',
age: 12,
address: 'Gulmi, Nepal'
};
let updatedInfo = { age: 21, address: 'Kathmandu, Nepal', ...myInfo};
console.log(updatedInfo);
console.log(myInfo);
let myInfo = {
name: 'Rabin Gaire',
age: 12,
address: 'Gulmi, Nepal'
};
let updatedInfo = Object.assign({}, myInfo);
updatedInfo.age = 21;
updatedInfo.address = 'Kathmandu Nepal';
let myInfo = {
name: 'Rabin Gaire',
age: 12,
address: 'Gulmi, Nepal'
};
let updatedInfo = myInfo;
updatedInfo.age = 21;
updatedInfo.address = 'Kathmandu Nepal';
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' }