A function in JavaScript is a block of code that performs a specific task and can be called or executed multiple times.
Function code block which can be reused to perform a specific task.
1. Inbuilt​
In JavaScript, inbuilt functions already have predefined meanings for various tasks. This means that the meaning is already defined and known to JavaScript.
Example :
alert() : An alert box will be displayed that contains a message along with an OK button.
prompt() :A prompt box displays an additional input field for the user to provide a value for output.
console.log() : You can use the browser console to display messages or values.
parseInt() : Converts a string into an Integer.
parseFloat() : Converts a string into a Floating-point number.
2. User Define​
By using the function keyword, to create and define your own functions known as user-defined functions.
Syntax :
function <function-name> ()
{
}