JS Daily #36 - Eval
What is the output of following code?
var b = 20; eval('var b = 10'); console.log(b);
The output is
eval() evaluates the passed argument string as an expression. Here, the expression is changing the value of
b from 20 to 10. That is why the output prints
eval() can dynamically change the scope and flow of code, it is advised NOT to use it whenever possible.