JSLint and JSHint (prior to version 1.0.0) will throw the "eval is evil" error when they encounter an invocation of the eval function. Here's an example in which we use eval to access an object property:
There are numerous reasons for this error. Some of the major ones include potentially dangerous code and a likelihood of a misunderstanding of the language. It can also indicate slow, inefficient code. For more details, Angus Croll's article How evil is eval? is highly recommended.
The eval function is slow. If you're using it unecessarily, you're slowing down your program for no reason. The cause of this is the fact that the engine has to parse the argument as a complete new program (ES5 §184.108.40.206):
When the eval function is called with one argument x, the following steps are taken:
1. If Type(x) is not String, return x.
2. Let prog be the ECMAScript code that is the result of parsing x as a Program.
However, in the situation where you absolutely have to use eval, you can tell both JSLint and JSHint to allow it. But you should only do this as a last resort. Just set the evil option to true:
In JSHint 1.0.0 and above this warning has changed to "eval can be harmful". More detail can be found the page dedicated to that message.