Object.assign() - weird behaviour need explanation
问题 I've got this code: function margeOptions(options, passedOptions) { options = Object.assign(options, passedOptions); } let passedOpts = {a: true}; let opts = {a: false}; margeOptions(opts, passedOpts); console.log(opts); // as expected returns {a: true} but when I change function a little bit, like this: function margeOptions(options, passedOptions) { options = Object.assign({}, options, passedOptions); } let passedOpts = {a: true}; let opts = {a: false}; margeOptions(opts, passedOpts);