DEV Community

Discussion on: Traditional Functions or Arrow Functions in Javascript?

Collapse
 
thomasstep profile image
Thomas Step

The order matters. Declare it
into a variable and then call it.

I might be incorrectly interpreting what you're saying, but have you heard of IIFE? developer.mozilla.org/en-US/docs/G...
You can create a function and immediately call it while storing the result in a variable.

Collapse
 
savagepixie profile image
SavagePixie

I think the author was referring to the fact that function expressions aren't hoistered.

Collapse
 
jharteaga profile image
Jose Arteaga

Exactly! It was more related to hoisting. I mean, there must be an error if I call the function expression before its declaration. Otherwise with traditional functions it won't happened.

By the way, thanks for the information about IIFE, I will read up on it.

Collapse
 
thomasstep profile image
Thomas Step

I definitely misunderstood the first time through so I apologize for that.

Thread Thread
 
jharteaga profile image
Jose Arteaga

There's no problem Thomas! Thank you for your response and help.