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

122
Views
Using setTimout to execute a function written in arrow syntax gives me an error

When I execute this code I receive an error: Cannot access 'bye' before initialization

setTimeout(bye, 3000);

console.log('Hello');

let bye = () => console.log('Goodbye');

But if I change the function to regular function syntax, it executes as I would expect it to. Why is this happening, and is there a way to make this work with arrow syntax?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's called Hoisting, arrow functions don't allow for it so you have to declare them before calling them.

https://www.w3schools.com/js/js_hoisting.asp

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!