User Defined Functions in JavaScript
Functions in JavaScript
A JavaScript function is a block of code designed to perform a particular task. Its main advantage is code reusability. Therefore we can say that the same code with different arguments produces different results.
Defining a Function:-
To define a JavaScript function, use the function keyword, followed by a name, followed by a set of parentheses ().
The javaScript function syntax is:-
function name() {
//code to be executed
}
Calling a Function:-
To call a function, start with the name of the function, then follow it with the arguments in parentheses like name(). We can call a function multiple times. Another way to call a function is by putting its name followed by a dot and then call() method like name.call().