Table of content:
- What is a function in JavaScript?
- Declaring functions in JavaScript
- Naming functions in JavaScript
- Adding parameters to a function
- Adding return statement to functions
- Calling functions in JavaScript
- Using a function for a JavaScript alert
- Calling a function from another function
- Calling functions with parameters
- Calling functions with return statement
- Other ways to define functions
What is a function in JavaScript?
A function is a piece of script within another larger script. A function is use to perform one or multiple tasks according to what code is placed inside it.
Functions can be use to organize a script into parts that accomplish different things. Functions can be reused as many times as you wish by simply calling the function again.