What is the security risk of using the Function constructor?
const calc = new Function('a', 'b', 'return a + b');
The Function constructor is similar to eval() in terms of security risks. It can execute arbitrary JavaScript code from strings, making it vulnerable to code injection attacks. Like eval(), it can execute any code in the global scope, potentially compromising your application's security. Always use regular functions or arrow functions instead of the Function constructor.