Object.assign side effect

Run Settings
LanguageJavaScript
Language Version
Run Command
(() => { const x = { x: 'x', } const y = { y: 'y' } console.log(`x:`, x) console.log(`y:`, y) console.log(`Object.assign(x, y):`, Object.assign(x, y)) // Object.assign will manipulate the original object. console.log(`x:`, x) })() console.log(`========`) ;(() => { const x = { x: 'x', } const y = { y: 'y' } // In order to not replace the any object. console.log(`Object.assign({}, x, y):`, Object.assign({}, x, y)) console.log(`x:`, x) })()
Editor Settings
Theme
Key bindings
Full width
Lines