Created
March 24, 2019 01:27
-
-
Save alexnault/8809663a02ddb96612ca3e6d521f13c5 to your computer and use it in GitHub Desktop.
Immutabilty example in JavaScript
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
// mutable | |
const bands = ["Metallica", "Queen"]; | |
bands.push("Nirvana"); | |
// immutable | |
const someBands = ["Metallica", "Queen"]; | |
const bands = [...someBands, "Nirvana"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment