JavaScript – Object Function

What is a function?

Function is defined as set of systematic procedure followed to attain a particular goal.

What is a function in programming language ?

Functions in programming language is considered as block of standard codes which can be reused by calling multiple times inside the program which provides the desired output, without re-typing the code again and again.

What is a function in javascript ?

in javascript function is a keyword, defined as block of code can be called one or mutiple times when it is called inside the program to get the desired output.

What is javascript object function ?

Function Object is created by Function Constructor and will be executed globally.

So if we call the constructor directly it will create a function object, which will be in unsecured way.

Javascript full course free !!!

Click to Learn More about – Javascript online learning

Syntax :

new Function ([arg1[, arg2[, ....argn]],] functionBody)  

arg1, arg2, …. , argn  

It represents the argument used by function.


It represents the function definition.

Example :

<!DOCTYPE html>
		<title>Our title</title>
		<script type="text/javascript">

			var a = 10;
			var b = 20;
			var addition = new Function(a,b,add(a,b));
			document.write("The value of a = " +a+'<br>'); 
			document.write("The value of b = " +b+'<br>'); 
			document.write("The value of addition = " + addition +'<br>');
			function add(a,b){
				return (a+b);

Output :

The value of a = 10

The value of b = 20

The value of addition = 30

There are few methods in Javascript object functions listed below,

SnoMethod / FunctionDescription
1apply()apply() method is used to call a function contains this value and a single array of arguments.
2bind()bind() method is used to create a new function.
3call()call() method is used to call a function contains this value and an argument list.
4toString()toString() method returns the result in a form of a string.