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
MDN object tutorial
- Loading branch information
Showing
1 changed file
with
50 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,50 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>MDN Object Tutorial</title> | ||
</head> | ||
|
||
<body> | ||
<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 myDataName = "height"; | ||
const myDataValue = "1.75m"; | ||
person[myDataName] = myDataValue; | ||
|
||
const person1 = { | ||
name: "Chris", | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}, | ||
}; | ||
const person2 = { | ||
name: "Deepti", | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}, | ||
}; | ||
|
||
function Person(name) { | ||
this.name = name; | ||
this.introduceSelf = function () { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}; | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |