codemarch
codemarch

@codemarch

9 Tweets 11 reads Aug 14, 2022
📌JavaScript Functions 🔥
Thread 🧵
JavaScript functions make it possible to repeat code snippets without having to write them out again and again.
➡️JavaScript Function Syntax.
➡️ JavaScript Function Creation:
You must first define a function before you can create it. This is accomplished by using the keyword function, followed by the name of the function, and then a curly parenthesis.
👇
➡️Function Invocation
The () Operator Invokes the Function.
The code inside the function will execute when "something" invokes (calls) the function:
1. When an event occurs.
2. When it is invoked (called) from JavaScript code.
3. Automatically (self-invoked).
Example:-
➡️Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was called from a statement, JavaScript will "return" to execute the code after the calling(invoking) statement.
Functions often compute a return value.
➡️Why do we need functions?
A function is a block of code that you can create and reuse anywhere in your code. Functions are useful for two reasons:
1. They make your code more organized and readable.
2. They save you time and effort.
➡️Functions Used as Variable Values
Functions can be used the same way as you use variables, in all types of formulas, assignments, and calculations.
for example instead of using a variable to store the return value of a function:
If you enjoyed reading this thread, please do the following:
1. Like the thread❤️
2. Retweet the first tweet.🔃
3. Follow me and enable notifications: ✅
@CodeMarch
Thank you for reading all the way through.

Loading suggestions...