// So, you have object like this
const obj = {
firstName: "John",
lastName: "Doe"
}
//Please create second object, that have firstName and lastName
// properties from first object.
// properties from first object.
console.log(myClonedObject) // {firstName: "John", lastName: "Doe"}
// Your goal is copy only properties, not the reference to object.
// so when we change first object like this :
// so when we change first object like this :
obj.firstName = "Mary"
// output on cloned object should look the same.
console.log(myClonedObject) // {firstName: "John", lastName: "Doe"}
// Please post your answer as codepen, jsbin or link into your github gist.
Brak komentarzy:
Prze艣lij komentarz