JavaScript Functions - How Functions Work in JavaScript
JavaScript Functions
JavaScript functions are used to perform some operations. We can call JavaScript function many times to reuse the code.
1. Code reusability :
- We can able to call the function several times so it save coding.
2. Less coding :
- It makes our program more simple and easy. We don’t need to write many lines of code each time to perform the same task.
Sample Code
Output
Function with Return Value
- We can call function that returns a value and use it in our program. Let’s see the example of function that returns value.