File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
14 - JavaScript References VS Copying Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments