Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda