eval()

eval(code) runs a string and returns its last value. A direct call sees local variables; an indirect one such as (0, eval)(code) runs globally. String objects are returned unevaluated.

Direct and indirect eval, and the Function constructorJavaScriptLive
globalThis.x = 'global';
function demo() {
  const x = 'local';
  const double = new Function('a', 'return a * 2');
  console.log(eval('x'), (0, eval)('x'), typeof eval(new String('1')), double(6));
}
demo();