forked from bpd01001/2024-spring-dmd-3475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
finished mdn object walkthrough
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!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: { | ||
first: "Bob", | ||
last: "Smith", | ||
}, | ||
age: 32, | ||
bio() { | ||
console.log(`${this.name.first} ${this.name.last} is ${this.age} years old.`); | ||
}, | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name.first}.`); | ||
}, | ||
}; | ||
|
||
const person1 = { | ||
name: "Chris", | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}, | ||
}; | ||
|
||
const person2 = { | ||
name: "Deepti", | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}, | ||
}; | ||
|
||
const myDataName = "height"; | ||
const myDataValue = "1.75m"; | ||
person[myDataName] = myDataValue; | ||
</script> | ||
</body> | ||
|
||
</html> |