let person = {
fanme: "Jitendra",
lname: "Singh",
};
let person1 = person;
person2.lname = "pal";
// It will change the original object (person1)
let person2 = Object.assign({}, person);
person2.lname = "mishra";
// It will not change the original object
let person3 = Object.create(person);
person3.lname = "yadav";
// It will not change the original object
let person4 = {...person};
person4.lname = "pandey";
// It will not change the original object
console.log(person);
console.log(person2)
console.log(person3);
console.log(person4);
https://jsfiddle.net/jitsingh79/cvqz1j3h/31/
No comments:
Post a Comment