Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to define a JavaScript function using Function() Constructor?
The Function() constructor expects any number of string arguments. The last argument is the body of the function - it can contain arbitrary JavaScript statements, separated from each other by semicolons.
Example
You can try to run the following code to invoke a function with new Function Constructor −
<html>
<head>
<script>
var func = new Function("x", "y", "return x*y;");
function multiplyFunction(){
var result;
result = func(15,35);
document.write ( result );
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "multiplyFunction()" value = "Call Function">
</form>
</body>
</html> Advertisements
