Last active
September 14, 2017 09:33
-
-
Save colevandersWands/e699be4022a5ec9dfbab032adea18b56 to your computer and use it in GitHub Desktop.
using Object.assign to clone an object or to modify an object
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
function assign_as_cloner(target_obj, source_obj) { | |
return Object.assign({}, target_obj, source_obj) | |
}; | |
function assign_as_modifier(target_obj, source_obj) { | |
Object.assign(target_obj, source_obj); | |
}; | |
// https://javascript.info/object#copying-by-reference |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment