Difference between a function and expression?

what is the difference between a function and an expression?

Why would you use an expression over a regular function? vice versa?

I get the impression you’re getting us to answer your homework questions for you.
Here, go read this from 8 years ago: https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/

1 Like

I get the impression you’re getting us to answer your homework questions for you.

No! I’m a web developer who always has homework cause I’m an web autodidact! LOL.
And if you’ve noticed from one of my last postings. When you ask a simple foundational question on what something is in JS, you GET A MILLION DIFFERING OPTIONS (some of which are more valid than others).

I’m a newbie trying to sort through the proliferation towards expertise, that’s all. Thanks for the resource.


I guess with regular functions you mean function declarations as opposed to function expressions… well a good rule of thumb is to always use function expressions (the article provided by @m_hutley explains why).

LOL yeah :-X

Please keep the replies on topic. I deleted some replies that were uncalled for.

OP has a very good question that I spent some time this morning digging into some documentation to try and answer and ended up learning a lot. I’m traveling today so I can’t give a good technical answer.

Functions and expressions are mathematical terms that I’ve personally always taken for granted and never really dug into what they actually mean at a deeper level in programming. This is a very interesting question, so please keep it civil.

There are good articles about this on MDN and 2ality. If 2ality thinks it’s enough to write a blog post on, it’s enough for a question here. That guy is one of the brightest in our industry.

1 Like

Found the one on 2ality: http://2ality.com/2012/09/expressions-vs-statements.html


^ _ ^

1 Like

Thanks, that’s one of them. I think there was another. I can look for it when I get stable internet again.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.