What is a javascript function constructor?
-
Function Constructor.
A function can be defined using the function keyword or using a built-in Javascript function constructor, called
Function( )
A normal function declaration. Here the function is called "hello"
function hello() { console.log('Hello world'); } hello();
A function using the function constructor.
let myNumber = new Function("a", "b", "return a * b"); let sum = myNumber(4, 3); console.log(sum)
© Lightnetics 2024