Basic JavaScript Question: Download JavaScript PDF

How to create a function using function constructor?

Tweet Share WhatsApp

Answer:

The following example illustrates this
It creates a function called square with argument x and returns x multiplied by itself.
var square = new Function ("x","return x*x");

Download JavaScript PDF Read All 114 JavaScript Questions
Previous QuestionNext Question
What does break and continue statements do in JavaScript? What's Prototypes for JavaScript?