Builtin functions and objects defined in the JavaScript standard library can be shadowed or redefined in user code. This is confusing and makes code hard to understand, so it should be avoided.

Refactor the code to avoid shadowing or redefinition. For example, if a local variable has the same name as a standard library builtin, it should be renamed.

In the following example, the user-defined function eval shadows the builtin function eval defined in the standard library. It could be renamed evaluate to avoid confusion.

  • Ecma International, ECMAScript Language Definition, 5.1 Edition, Section 15. ECMA, 2011.