r/JavaScriptTips • • Nov 08 '22

Difference between Function Declaration and Function Expression

We are already familiar with two ways of defining functions:

function greet() {}

and

const greet = function() {}

But how are they different and when to use one over the other? Most developers aren’t sure on using which one and often tend to use the wrong one. Check out the post to find out these answers.

13 Upvotes

4 comments sorted by

2

u/[deleted] Nov 08 '22

Well explained, thanks

1

u/Medical-Swim3101 Nov 08 '22

Thanks for the post

1

u/Basediver210 Nov 09 '22

Thanks. Im coming from other programming languages, and the difference doesn't seem to stick for me. This helped

1

u/Prasham_4536 Nov 11 '22

Superb explanation πŸ‘πŸΌπŸ‘πŸΌ