Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!