Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Last active September 14, 2017 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colevandersWands/e699be4022a5ec9dfbab032adea18b56 to your computer and use it in GitHub Desktop.
Save colevandersWands/e699be4022a5ec9dfbab032adea18b56 to your computer and use it in GitHub Desktop.
using Object.assign to clone an object or to modify an object
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