
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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>
- Related Articles
- How to invoke a function with a function constructor in JavaScript?
- How to define a JavaScript function using the expression?
- How to invoke a JavaScript Function with 'new' Function Constructor?
- How to define a function in JavaScript?
- How do we use function literal to define a function in JavaScript?
- How to define global variable in a JavaScript function?
- Accessing variables in a constructor function using a prototype method with JavaScript?
- What is function() constructor in JavaScript?
- How to define an Arrow Function in JavaScript?
- How to define custom sort function in JavaScript?
- How to define functions inside a function body in JavaScript?
- How to define rest parameter for a function in JavaScript?
- How to define a function Using the WITH clause in Oracle?
- How to define a function in Python?
- How to delay a JavaScript function call using JavaScript?

Advertisements