-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoojs.html
More file actions
38 lines (36 loc) · 1006 Bytes
/
Copy pathoojs.html
File metadata and controls
38 lines (36 loc) · 1006 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Object-oriented JavaScript example</title>
</head>
<body>
<p>
This example requires you to enter commands in your browser's JavaScript
console (see
<a
href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools"
>What are browser developer tools</a
>
for more information).
</p>
<script>
const person = {
name: ["Bob", "Smith"],
age: 32,
bio: function () {
console.log(
`${this.name[0]} ${this.name[1]} is ${this.age} years old.`
);
},
introduceSelf: function () {
console.log(`Hi! I'm ${this.name[0]}.`);
},
};
const myDataName = "height";
const myDataValue = "1.75m";
person[myDataName] = myDataValue;
</script>
</body>
</html>