function in javascript

function in javascript

Function contains statements which can perform various tasks.

Function are used to avoid repetition of codes.

function definition

Syntax

function function_name([arguments])
{
----
----
----
}

function calling

Syntax

function_name([arguments]);

arguments - It is optional, it is used to pass values from function calling to function definition.

Example

Try Yourself

Example - function calling with a argument

Try Yourself

Example - function calling with multiple arguments

Try Yourself