Created
December 27, 2020 07:37
-
-
Save yurtarmehmet/253c03a87d7e8e25bdbb022c31e00135 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// COPYING OBJECTS | |
// foreach | |
const person = {name: "John", age: 30, children: [{name:"JOHNNY"}]}; | |
const newPerson = {}; | |
Object.keys(person).forEach((personField) => { | |
newPeople[personField] = person[personField] | |
}); | |
// object assign | |
const newPerson = Object.assign({}, person); | |
// spread ... | |
const newPerson = {...person}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment