<html>
<body>
<h1>JavaScript Objects</h1>
<h2>Adding a Method</h2>
<p id="demo"></p>
<script>
// Create an Object
const person = {
firstName: "John",
lastName: "Doe",
id: 5566,
};
// Add a Method
person.name = function() {
return this.firstName + " " + this.lastName;
};
// Display Object Data
document.getElementById("demo").innerHTML =
"My father is " + person.name();
</script>
</body>
</html>