Implement eval() as a sentinel-intercepted builtin that parses and executes code strings at runtime with proper scope and strict mode handling. Direct eval inherits caller scope (vars leak in non-strict), while indirect and strict eval contain declarations via function scope. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 lines
265 B
JavaScript
9 lines
265 B
JavaScript
// Basic eval() — expression evaluation, non-string passthrough, typeof
|
|
console.log(eval("1 + 2"));
|
|
console.log(eval(42));
|
|
console.log(eval(true));
|
|
console.log(eval());
|
|
console.log(eval("1; 2; 3"));
|
|
console.log(typeof eval);
|
|
console.log(eval("eval('10 + 20')"));
|