Skip to content

Commit ba7cb7e

Browse files
committed
Adding some notes to day 14
1 parent a44756b commit ba7cb7e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

14 - JavaScript References VS Copying/index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,21 @@
8686
facebook: 'wesbos.developer'
8787
}
8888
};
89-
9089
console.log(wes);
9190

9291
const dev = Object.assign({}, wes);
9392
dev.social.twitter = '@Pencilvestyr'
9493
console.log(wes, dev);
94+
console.log('Shallow but performant');
9595

9696
const dev2 = JSON.parse(JSON.stringify(wes));
97-
dev2.social.twitter = '@Hamurai'
97+
dev2.social.twitter = '@Hamurai';
9898
console.log(wes, dev2);
99+
console.log('Double encoding via JSON is super ineffcient.');
100+
console.log('But you get deep cloning of attributes out of it.');
101+
console.log('However, if your object has any methods on it, your SOL.');
102+
console.log('JSON doesn\'t grok methods.');
103+
99104
</script>
100105

101106
</body>

0 commit comments

Comments
 (0)