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

Programming
Tutor: None Selected Time limit: 1 Day

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

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Aug 8th, 2015
...
Aug 8th, 2015
Dec 8th, 2016
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