December 21, 2022
Estimated Post Reading Time ~

About Javascript functions in brief

About Javascript functions in brief
What are functions?

→ A function in general sense is a set/block of code that is created to perform a task

→ We call a function to execute the code inside it.

→ think of this as a particular action or set of steps to take when an event occurs.

→ functions can contain the same set of steps or even a single step to be performed.

Javascript function Syntax
→ it is defined with the keyword function, which is followed by a name and a parentheses ().

→ function naming rules are same as variables!

Example of a function that adds two numbers:
What is the return statement?

→ we can return a specific value in a function with a return statement, and the function stops executing when it reaches the return statement.

→ we mostly use the return statement when we want to stop the execution.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.