Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Why does the new key show different when we use Object.defineProperty() in javascript?

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>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!