The eval function is a way to run arbitrary code at run-time. Dynamically evaluating code is slow and a potential security issue when the arguments haven't been properly validated.

In general it is better to avoid it altogether, particularly when there are safer alternatives.

Noncompliant Code Example

var value = eval('obj.' + propName); // Noncompliant

Compliant Solution

var value = obj[propName];

Exceptions

This rule will not raise an issue when the argument of the eval call is a literal string as it is reasonably safe.

See