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

167
Vistas
Changing how an object/function is represented in a console.log statement

I am trying to customize how an instance is printed in a console.log statement by default:

function Vehicle(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
    this.speed = 0;
    this.engineOn = false;
}

Vehicle.prototype.valueOf = function() {
    return 'print this';
}

let v = new Vehicle(1,2,3);
console.log(v);

It seems there is a valueOf and a toString function, but neither of those seem to change the value. How would I properly change the default format when it's cast to a string in the console.log statement?

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