In Javascript, what is the better choice between function declaration and function expression?

label Programming
account_circle Unassigned
schedule 1 Day
account_balance_wallet $5

Do you use them on a case by case basis or should you stick to one choice for consistency? Is there a performance difference between the two that makes them matter in real world applications?

Aug 8th, 2015

Thank you for the opportunity to help you with your question!

Function declaration and function expression should be used case by case.

The perfomance difference is that:

Even though they seem similar, the difference lies in how the browser loads them. Functions declaration loads before any code is executed while function expressions loads only when the interpreter reaches that line of code. Thus working together improves performance.


Please let me know if you need any clarification. I'm always happy to answer your questions.
Aug 8th, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Aug 8th, 2015
...
Aug 8th, 2015
Jun 28th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer