Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created October 19, 2016 00:21
Show Gist options
  • Save nobeans/8fae2c6c084dad3d029c64b10e0804aa to your computer and use it in GitHub Desktop.
Save nobeans/8fae2c6c084dad3d029c64b10e0804aa to your computer and use it in GitHub Desktop.
var l = [1, 2, 3];
var l2 = Object.assign([], l, [4, 5]);
var l3 = l.concat();
l3[1] = "X";
console.log(l);
console.log(l2);
console.log(l3);
var l4 = l3.map(function(it) {
if (it === 'X') {
return 'Z';
}
return it;
});
console.log(l3);
console.log(l4);
var o = {
b: "B",
c: "C",
"a": "A"
};
console.log(o);
console.log(Object.keys(o));
var o2 = Object.keys(o).map(function(it) {
if (it === "c") {
return "C!!!!!";
}
return it;
});
console.log(o2);
o["c"] = "C?"
console.log(o);
var o3 = Object.assign({}, o);
o3["c"] = "C???????"
console.log(o);
console.log(o3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment