Function :
A JavaScript function is a reusable block of code that groups together a sequence of statements to perform a particular task.
Function declarations :
JavaScript function declaration starts with…
- The function keyword,
- Parentheses are used next to the name of the function or its identifier,
- A function body or the block of statements enclosed in curly braces.
Here,
() : between the parentheses contains single or multiple parameters separated by commas.
{}: between the curly braces is the function body or the JavaScript statement where a code block is to be executed.
Call or Invoke a function:
Only function declaration will not execute or run the code inside the function body. Function declaration means to declare the existence of a function.
If we want to execute or run the code inside a function body, then we have to call a function in our code by typing the function name followed by parentheses.
Post a Comment