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

192
Vistas
Why console.log.apply("some string") doesn't work?

Why console.log.apply("some string") doesn't work ?

Trying to apply the method .log() to some string or any other variable fails.

For example:

let x = 100;
console.log.apply(x); // doesn't display 100 !

Also, no matter what I use for that variable it doesn't work, either array or object.

let y = [100, 200];
let z = new Date();

console.log.apply(y); // doesn't display [100, 200]
console.log.apply([100, 200]); // doesn't display [100, 200] either

console.log.apply(z); // doesn't display the Date object
console.log.apply({car: "Ford", price: 25000}); // nothing, too
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The first argument of .apply this the value of this from the context of the function being executed. The second argument is an array of values being passed as arguments to the function.
So you should pass the array as the second argument:

console.log.apply(null, ["hello"]);

Further documentation can be found on MDN

about 4 years ago · Santiago Trujillo 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