Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda