JS Built-ins
FunctionFunctionbeginner

Function() β€” typeof a new Function()

πŸ“– Usage Example
const fn = new Function('a', 'b', 'return a + b')
fn(2, 3)  // β†’ 5

Function() creates a new function from a string of code at runtime.

Function constructor

The Function constructor creates a new Function object. The result of typeof a function instance is always 'function'.

Challenge: Verify that typeof new Function() returns 'function'.

πŸ’‘ Hints (2)
  • β€’ `new Function()` creates a new function object.
  • β€’ `typeof` a function always returns `'function'`.