-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable-playground.js
More file actions
44 lines (33 loc) · 977 Bytes
/
variable-playground.js
File metadata and controls
44 lines (33 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// -------object-------
let person = {
name: 'Serhat',
age: 21
};
let a = 5;
function updatePerson(person) {
let a = 4;
console.log(a);
person.age = 31; // not lose reference, update orginal object
// person = { // we lose the reference here!
// name: 'Serhat',
// age: 29
// };
console.log('inside: %o', person);
}
updatePerson(person);
console.log('outside: %o', person);
console.log(a);
// -------array-------
var grades = [15, 88];
function addGrades(gradesArr) {
gradesArr.push(35); // not lose reference, update orginal array
debugger;
// gradesArr = [12, 45, 99]; // we lose the reference here!
}
addGrades(grades);
console.log(grades);
// about debugger => tells node where to stop with the program
// *** node debug filename,, node inspect filename
// *** cont, continuous the program
// *** repl, we can inspect variables and functions inside of our code,,
// then type variable name for inspect