• Hi Tobias,

    I've just checked, and it's an issue with Espruino's implementation of the Function constructor. Basically it only looks for the code to run, and not for the optional list of arguments.

    So (new Function('console.log("Hello");'))() will work, but you won't be able to supply arguments.

    I've filed a bug for it here: https://github.com/espruino/Espruino/iss­ues/505

    If you want to work around it you could do:

    function newFunction(args, code) {
      return eval("(function("+args.join(",")+"){"+co­de+"})");
    }
    var x = newFunction([ 'a' ], 'console.log(a);');
    x.apply({}, [ 4 ]);
    
About

Avatar for Gordon @Gordon started