

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to invoke a JavaScript Function with 'new' 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 Questions & Answers
- How to invoke a function with a function constructor in JavaScript?
- How to invoke a JavaScript Function as a function?
- How to define a JavaScript function using Function() Constructor?
- How to invoke a JavaScript Function as a method?
- How to invoke a function as a function and method?
- JavaScript: lexical scoping issue using new keyword constructor while adding inner function?
- What is function() constructor in JavaScript?
- Accessing variables in a constructor function using a prototype method with JavaScript?
- How to call jQuery function with JavaScript function?
- Explain 'Not a constructor function' error in JavaScript?
- How to call a Java function inside JavaScript Function?
- How to stop the execution of a function with JavaScript?
- How to execute a Javascript function in Python with Selenium?
- How to call a function in JavaScript?
- How to define a function in JavaScript?
Advertisements