In this example bellow (source: W3school), when we put console.log('person',person); in the end, fullName is in a different color in the log of others (see the pic). Does it mean that fullname is temporary? What should I do to make it become part of person?
P.s: I'm begginner and I'm not able to put pictures here. thanks for understanding!
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Object.defineProperty()</h2>
<p>This example uses the defineProperty() method to add a getter and a setter.</p>
<p id="demo"></p>
<script>
// Create an object:
const person = {firstName:"John", lastName:"Doe"};
// Define a getter
Object.defineProperty(person, "fullName", {
get: function () {return this.firstName + " " + this.lastName;}
});
console.log('person',person);
// Display full name
document.getElementById("demo").innerHTML = person.fullName;
</script>
</body>
</html>