Skip to content

Commit aa4c81b

Browse files
author
Jin Xu
committed
course wesbos#14 learnt
1 parent 4ae2220 commit aa4c81b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

14 - JavaScript References VS Copying/index-START.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
const players = ['Wes', 'Sarah', 'Ryan', 'Poppy'];
1414

1515
// and we want to make a copy of it.
16+
let clone = [...players];
17+
console.log(clone)
1618

1719
// You might think we can just do something like this:
1820

@@ -41,10 +43,11 @@
4143
// and think we make a copy:
4244

4345
// how do we take a copy instead?
44-
46+
// {...obj}
4547
// We will hopefully soon see the object ...spread
4648

4749
// Things to note - this is only 1 level deep - both for Arrays and Objects. lodash has a cloneDeep method, but you should think twice before using it.
50+
// JSON.parse(JSON.stringify(obj))
4851

4952
</script>
5053

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
11. [ ] Custom Video Player
1818
12. [x] ~~Key Sequence Detection~~
1919
13. [x] ~~Slide in on Scroll~~
20-
14. [ ] JavaScript References vs. Copying
20+
14. [x] ~~JavaScript References vs. Copying~~
2121
15. [ ] LocalStorage
2222
16. [ ] Mouse Move Shadow
2323
17. [ ] Sort Without Articles

0 commit comments

Comments
 (0)