Created
April 25, 2017 15:43
-
-
Save kadikraman/349157a7de2917b9a6d81c3d81834665 to your computer and use it in GitHub Desktop.
JavaScript tips
This file contains hidden or 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
| /* | |
| Replacing an item in an array without mutating it | |
| */ | |
| const old = [1, 2, 3, 4]; | |
| const new = Object.assign([], old, {0: 1000}); | |
| console.log(new); | |
| // [1000, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment