Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 702b74d

Browse files
committed
continuing with wesbos#14...
1 parent 88da10a commit 702b74d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@
88

99
<script>
1010
// start with strings, numbers and booleans
11-
let age = 100;
12-
let age2 = age;
13-
console.log(age, age2); // 100 100
14-
age = 200;
15-
console.log(age, age2); // 200 100
16-
17-
let name = 'Wes';
18-
let name2 = name;
19-
console.log(name, name2); //Wes Wes
20-
name = 'wesley';
21-
console.log(name, name2); //wesley Wes
11+
// let age = 100;
12+
// let age2 = age;
13+
// console.log(age, age2); // 100 100
14+
// age = 200;
15+
// console.log(age, age2); // 200 100
16+
17+
// let name = 'Wes';
18+
// let name2 = name;
19+
// console.log(name, name2); //Wes Wes
20+
// name = 'wesley';
21+
// console.log(name, name2); //wesley Wes
2222

2323
// Let's say we have an array
2424
const players = ['Wes', 'Sarah', 'Ryan', 'Poppy'];
2525

2626
// and we want to make a copy of it.
27+
const team = players;
2728

29+
console.log(players, team);
2830
// You might think we can just do something like this:
31+
team[3] = 'Lux'; //updates both team and players
32+
//because we updated team, but team is not the array; team is just a reference to the original array, players.
2933

3034
// however what happens when we update that array?
3135

0 commit comments

Comments
 (0)