eval of course evaluates and runs any code passed to it as a string as does its less evil cousin the Function constructor. In the graph plotter I used the
Function constructor to create the mathematical function used to compute the corresponding
y values for each
In the above snippet the usage of
with is also included.
with modifies the scope chain used for lookup of unqualified names in the scope of with. Here’s an example.
with and all variations of
eval create the potential for disasters in security, undefined behaviour and bugs. The with statement even comes with the following warning on MDN:
Use of the with statement is not recommended, as it may be the source of confusing bugs and compatibility issues. See the “Ambiguity Con” paragraph in the “Description” section below for details.
However as seen in the code golf exercises above they are extremely powerful and that is also their problem, they are too powerful to be trusted.