Ajay Yadav Profile picture
โ€ข No-Code AI Tools โ€ข Mission on Simplified Web @theDivSoup โ€ข Technical Writer โ€ข DM open for collab โ€ข Mail ๐Ÿ“ฉ: partnership.aj@gmail.com

Mar 25, 2022, 9 tweets

๐Ÿ’› Day 2๏ธโƒฃ3๏ธโƒฃ / 3๏ธโƒฃ0๏ธโƒฃ days of basics in JavaScript series!

โ†’ What is a function declaration?

โ†’ What is a function statement?

โ†’ What is function expression?

โ†’ Difference between function declaration & function expression?

โ†’ What is an anonymous function?

#javascript30
๐Ÿงตโ‡ฉ

๐Ÿ“Œ What is a function declaration?

โ†’ A function declaration always starts with the "function" keyword.

โ†’ The function declaration must have a function name.

๐Ÿ“Œ What is a function statement?

โ†’ The function statement is the synonym of the function declaration.

โ†’ Both are the same.

๐Ÿ“Œ What is function expression?

โ†’ This is also a function but without a function name.

โ†’ A function expression can be stored in a variable using the (=) assignment operator.

โ†’ The function can be assigned in a variable as a value using the (=) assignment operator.

โ†’ And they are always called(invoke / run) using the name of the variable.

โ†’ Here "squares" is the name of the variable.

๐Ÿ“Œ Difference between function declaration & function expression?

โ†’ The main difference is that function declaration is hoisted but not function expression.

โ†’ We can call/invoke the function declaration "after" and "before" the function definition.

โ†’ But function expression can only invoke/run/call "after" the function definition.

โ†’ If we call the function expression before initialization, then this will give an error.

๐Ÿ“Œ What is an anonymous function?

โ†’ A function without a name is called an anonymous function.

๐Ÿ’š That's all for now, we will meet in the next thread!

But if you like make sure to:

1. Follow me @ATechAjay

2. Retweet the first tweet.

3. Turn on the notification to never miss these amazing tweets.

Thank you so much for staying to the end of this thread.

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling