Skip to content

Latest commit

 

History

History
10 lines (6 loc) · 310 Bytes

javaScriptNotes.md

File metadata and controls

10 lines (6 loc) · 310 Bytes

Data change without mutation

var player = {score: 1, name: 'Jeff'};

var newPlayer = Object.assign({}, player, {score: 2}); // Now player is unchanged, but newPlayer is {score: 2, name: 'Jeff'}

// Or if you are using object spread syntax proposal, you can write: // var newPlayer = {...player, score: 2};