Skip to content

Commit 9c1497d

Browse files
committed
objets
1 parent 260794c commit 9c1497d

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

playground/objects.html

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title></title>
8+
<link rel="stylesheet" href="../base.css">
9+
</head>
10+
11+
<body>
12+
<input type="text" name="first" value="wes">
13+
14+
<script src="https://unpkg.com/lodash"></script>
15+
<script>
16+
const age = 100;
17+
const wes = {
18+
age,
19+
name: 'wes',
20+
properyToCheck: 'NEVER',
21+
'cool-dude': true,
22+
'really cool': false,
23+
'777': true,
24+
dog: 'snicker',
25+
clothing: {
26+
shirts: 10,
27+
pants: 2
28+
},
29+
sayHello: function (greeting = 'Hey') {
30+
return `${greeting} ${this.name}`;
31+
}
32+
};
33+
34+
wes.job = 'Web Developer';
35+
wes.age = 50;
36+
37+
console.log(wes.age);
38+
// const properyToCheck = prompt('What do you want to check?');
39+
// console.log(properyToCheck);
40+
// console.log(wes[properyToCheck]);
41+
42+
const nameInput = document.querySelector('[name="first"]');
43+
const name = nameInput ? nameInput.value : '';
44+
console.log(name);
45+
46+
// console.log(delete wes.job);
47+
// wes.age = undefined;
48+
// wes.age = null;
49+
50+
let name1 = 'wes';
51+
let name2 = 'wes';
52+
53+
console.log(name1 === name2);
54+
name1 = 'scott';
55+
console.log(name1 === name2);
56+
// update name1 to be what is name2
57+
name1 = name2;
58+
console.log(name1 === name2);
59+
name2 = name1;
60+
name2 = 'westopher';
61+
62+
const person1 = {
63+
first: 'wes',
64+
last: 'bos',
65+
clothing: {
66+
shirts: 10,
67+
pants: 2
68+
}
69+
};
70+
const person2 = {
71+
first: 'wes',
72+
last: 'bos'
73+
};
74+
75+
// const person3 = person1;
76+
// person3.first = 'Larry';
77+
// console.log(person3.first);
78+
// console.log(person1.first);
79+
// const person3 = { ...person1 };
80+
const person3 = _.cloneDeep(person1);
81+
person3.first = 'Larry';
82+
83+
person3.clothing.shirts = 100;
84+
85+
const meatInventory = {
86+
bacon: 2,
87+
sausage: 3,
88+
oyster: 10,
89+
};
90+
91+
const veggieInventory = {
92+
lettuce: 5,
93+
tomatoes: 3,
94+
oyster: 15,
95+
};
96+
97+
const inventory = {
98+
...meatInventory,
99+
...veggieInventory,
100+
};
101+
102+
function doStuff(data) {
103+
data = 'something else';
104+
console.log(data);
105+
}
106+
107+
function doStuff2(data) {
108+
data.tomatoes = 10000000000;
109+
console.log(data);
110+
}
111+
112+
doStuff2(inventory);
113+
114+
115+
</script>
116+
</body>
117+
118+
</html>

0 commit comments

Comments
 (0)