https://stackoverflow.com/questions/50098277/why-let-keyword-does-not-work-with-eval/50098375 why let keyword does not work with eval() function foo(str, a) { eval( str ); console.log( a, b ); } foo( "var b = 3;", 1 ); This works just fine, but when we use let instead of var, it does not work. Why? stackoverflow.com