How to convert string to real javascript object if we don't use new Function
var sum = new Function('a', 'b', 'return a + b')
console.log(sum(2, 6))
So 'a', 'b', 'return a + b'
is generated by another javascript snippet and everything is string format.
eslint suggests do not use Function constrctor The Function constructor is eval. (no-new-func)
If not using Function constrctor
is there another option can do the same job? Thanks