Created
September 1, 2017 01:16
-
-
Save justanotherdot/de917b62479ba8acaa880fce0aa479be to your computer and use it in GitHub Desktop.
Object.assign is shallow
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
'use strict'; | |
var obj0 = { | |
a: { | |
b: 12 | |
} | |
}; | |
var obj1 = Object.assign({}, obj0); // Similar to object spread. | |
obj1.a.b += 12; | |
console.log('obj0', obj0.a); | |
console.log('obj1', obj1.a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment