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

299
Views
Why are there different ways to create a function in JavaScript? (Hoisting?)

I know that there are 3 ways of creating functions

Function Declaration. Function Expression. Arrow Function.

function foo(){
console.log("boo");
{

and

var foo = function(){
console.log("boo");
}

I know that the first one is hoisted so that even if we call it before the function it will work. For the second one because it is an assigned variable hoisting will not work.

My question why is there such a requirement? I just started learning JS and it does not make sense to me yet to set the difference between those two.

Also how about Arrow Function? Why do we need it as well?

Thank you

Edit1: I found my answer for the question of Arrow Functions which seems too advanced for me. I will review it as I go.

When should I use arrow functions in ECMAScript 6?

I am still not clear about the difference between Function Declaration and Function expression.

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