I need to call a function but it is given as a string (originally it is much more complex and includes many more nested m() functions.):
m()
\"m(\'p\',
In order to use the function m in that code string, you need to pass it as a parameter to the function:
m
const m = require(...); const f = new Function("m", "m('p', {class:'red'}, 'text')"); f(m);