Function() vs new Function()

Edit on GitHub

Setup

Tests

  • Function()

    const fun = Function('a', 'b', 'return a + b');
    fun(1, 2);
  • new Function()

    const fun = new Function('a', 'b', 'return a + b');
    fun(1, 2);