In JavaScript, is there any way to create function object from function definition in a String?
Something similar to a JSON.parse for creating JSON from a String.
const parseFunction = (str)=> {
// What should be implemented here?
return func;
}
let funStr = parseFunction("function replacer(arg1) {console.log(arg1)}");
eval?new Function(str)? Just pass the function body instead