+ 3
Closures of function-object constructors. Fix this code or Elaborate this code
//basic code let person = new Function("a","b","return a+b"); console.log("Non-Error: "+person(1,2));//3 //own code let personA = new Function("a","b","return ()=>a+b"); console.log("Error 1: "+personA(1,2));//Error 1:()=> a+b //own method let createperson = new Function("name","age", "return function(){ let user = {};user.name=name;user.age=age;return user;}"); console.log("Error 2: "+createperson.name); //Error 1:anonymous
1 Respuesta
+ 3
According to the code
Error 1 : ()=> a+b;
I think it's returns a string of method which is function defined in an object