Home HTML CSS JAVASCRIPT BOOTSTRAP Python Docker ML tutorial About us Privacy policy

Functions In JavaScript



Functions



javaScript functions are block of statement which are used to perform various task according to the requirement. Functions will be executed if and only if, when someone invoked them.

Syntax

javaScript functions define by using function keyword ,followed by name . Function names can be letters,digits etc. Functions can contain parameters as well . Functions always start's and end with {}.
function functionName(parameter1,parameter2,etc)
{
  //function body
}

Function Invocation

Function invocation is a equaly important just like function defination because without invoke a function there is no use of a function. We can invoke a function manully inside javaScript code or fire an javaScript event to click to button.

Function Return Value

Function always return values.We use return statement to return a value,It's always last statement inside the function.

Functions behaviour like variables

We can also use functions just like a variables. just store the result of a function inside a variable and use it like a normal variable.