forked from wesbos/beginner-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects-FINISHED.html
More file actions
118 lines (97 loc) · 2.34 KB
/
objects-FINISHED.html
File metadata and controls
118 lines (97 loc) · 2.34 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title></title>
<link rel="stylesheet" href="../base.css">
</head>
<body>
<input type="text" name="first" value="wes">
<script src="https://unpkg.com/lodash"></script>
<script>
const age = 100;
const wes = {
age,
name: 'wes',
properyToCheck: 'NEVER',
'cool-dude': true,
'really cool': false,
'777': true,
dog: 'snicker',
clothing: {
shirts: 10,
pants: 2
},
sayHello: function (greeting = 'Hey') {
return `${greeting} ${this.name}`;
}
};
wes.job = 'Web Developer';
wes.age = 50;
console.log(wes.age);
// const properyToCheck = prompt('What do you want to check?');
// console.log(properyToCheck);
// console.log(wes[properyToCheck]);
const nameInput = document.querySelector('[name="first"]');
const name = nameInput ? nameInput.value : '';
console.log(name);
// console.log(delete wes.job);
// wes.age = undefined;
// wes.age = null;
let name1 = 'wes';
let name2 = 'wes';
console.log(name1 === name2);
name1 = 'scott';
console.log(name1 === name2);
// update name1 to be what is name2
name1 = name2;
console.log(name1 === name2);
name2 = name1;
name2 = 'westopher';
const person1 = {
first: 'wes',
last: 'bos',
clothing: {
shirts: 10,
pants: 2
}
};
const person2 = {
first: 'wes',
last: 'bos'
};
// const person3 = person1;
// person3.first = 'Larry';
// console.log(person3.first);
// console.log(person1.first);
// const person3 = { ...person1 };
const person3 = _.cloneDeep(person1);
person3.first = 'Larry';
person3.clothing.shirts = 100;
const meatInventory = {
bacon: 2,
sausage: 3,
oyster: 10,
};
const veggieInventory = {
lettuce: 5,
tomatoes: 3,
oyster: 15,
};
const inventory = {
...meatInventory,
...veggieInventory,
};
function doStuff(data) {
data = 'something else';
console.log(data);
}
function doStuff2(data) {
data.tomatoes = 10000000000;
console.log(data);
}
doStuff2(inventory);
</script>
</body>
</html>