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

193
Vistas
Difference between what's passed natively to console.log and toString

In the following example:

let s = {x: 1, y: 1};
console.log(s, s.toString());

Where is the '[object Object]' method defined? Why does printing an object evaluate to something different than doing object.toString() ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Various environments' consoles are generally intended for (and hence optimized for) debugging. If you log an object, the console is likely to show you a full, readable, interactive view of the object. The console does not convert logged values to strings before displaying them - that wouldn't be useful for debugging.

When an object has Object.prototype.toString called on it, it's required to go through these steps in the specification, which will result in [object SOMETHING] being logged, where SOMETHING may be Array, Function, etc, or Object if none of those special cases match. For a plain object, none of the special cases match, so you get [object Object].

about 4 years ago · Juan Pablo Isaza Denunciar

0

Replace s.string() with JSON.stringify()...

Refer here... What's the difference in using toString() compared to JSON.stringify()? for further

about 4 years ago · Juan Pablo Isaza Denunciar
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