This Gist was automatically created by Carbide, a free online programming environment.
Created
August 25, 2017 18:24
-
-
Save carbide-public/98ddd6b703267ee39a8b612d10483ae6 to your computer and use it in GitHub Desktop.
untitled
This file contains 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
import Immutable from 'seamless-immutable' | |
console.clear() | |
var array = Immutable(["totally", "immutable", { hammer: "Can’t Touch This" }]); | |
try { | |
array[1] = "I'm going to mutate you!" | |
} catch (err) { | |
console.log(err) | |
console.log('array[1]', array[1]) // "immutable" | |
} | |
try { | |
array[2].hammer = "hm, surely I can mutate this nested object..." | |
} catch (err) { | |
console.log(err) | |
console.log('array[2].hammer', array[2].hammer) // "Can’t Touch This" | |
} | |
console.log(JSON.stringify(array)) // '["totally","immutable",{"hammer":"Can’t Touch This"}]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment