Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d4e390

Browse files
JavaScript References VS Copying
1 parent 5e9f139 commit 3d4e390

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

‎14_day/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>14 Day</title>
7+
</head>
8+
9+
<body>
10+
<p><em>Please have a look at the JavaScript Console</em> 💁</p>
11+
<script type="text/javascript" src="main.js"></script>
12+
</body>
13+
14+
</html>

‎14_day/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎14_day/main.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const players = ['Wes', 'Sarah', 'Ryan', 'Poppy'];
2+
3+
const team = players;
4+
5+
console.log(players, team);
6+
7+
const team2 = players.slice();
8+
9+
const team3 = [].concat(players);
10+
11+
const team4 = [...players];
12+
team4[3] = 'heeee hawww';
13+
console.log(team4);
14+
15+
const team5 = Array.from(players);
16+
17+
const person = {
18+
name: 'Wes Bos',
19+
age: 80
20+
};
21+
22+
const cap2 = Object.assign({}, person, {
23+
number: 99,
24+
age: 12
25+
});
26+
console.log(cap2);
27+
28+
const wes = {
29+
name: 'Wes',
30+
age: 100,
31+
social: {
32+
twitter: '@wesbos',
33+
facebook: 'wesbos.developer'
34+
}
35+
};
36+
37+
console.clear();
38+
console.log(wes);
39+
40+
const dev = Object.assign({}, wes);
41+
42+
const dev2 = JSON.parse(JSON.stringify(wes));

‎README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,8 @@ Tool Found: It's so easy now to convert our ES5 code into readable ES6 using [le
6666
### Day 12: 29 Jun 2018
6767
Learned about key sequence detection & Konami code. Also, found that [BuzzFeed site](https://www.buzzfeed.com/)'s hidden easter egg is still working. To see it in action just press ':arrow_up: :arrow_up: :arrow_down: :arrow_down: :arrow_left: :arrow_right: :arrow_left: :arrow_right: B A'.
6868

69-
### Day 13: 11 Jan 2017
69+
### Day 13: 30 Jun 2018
7070
Learned a bit more about window events & a very useful javascript debounce function. Today's project helped me to fix an issue related to resize events which was slowing down our site. The goal behind debounce implementation is to reduce overhead by preventing a function from being called several times in succession.
71+
72+
### Day 14: 1 Jul 2018
73+
Learned more about array & object reference vs actual copy. Found that primitive types are manipulated by value & reference types are manipulated by reference. Numbers and booleans are primitive types in JavaScript -- primitive because they consist of nothing more than a small, fixed number of bytes that are easily manipulated at the low (primitive) levels of the JavaScript interpreter. Objects, on the other hand, are reference types. Arrays and functions, which are specialized types of objects, are therefore also reference types. These data types can contain arbitrary numbers of properties or elements, so they cannot be manipulated as easily as fixed-size primitive values can. Since object and array values can become quite large, it doesn't make sense to manipulate these types by value, as this could involve the inefficient copying and comparing of large amounts of memory.

‎index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<a class="active" href="./11_day/index.html">11 Day</a>
2323
<a class="active" href="./12_day/index.html">12 Day</a>
2424
<a class="active" href="./13_day/index.html">13 Day</a>
25+
<a class="active" href="./14_day/index.html">14 Day</a>
2526
</div>
2627
</body>
2728

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /