When writing asynchronous code, it is possible to create subtle race condition bugs. Consider the following example:
Object.prototype
builtins should not be used directly JS-0021It is preferable to call certain Object.prototype
methods through Object
on object instances instead of using the builtins directly.
It is considered a best practice to avoid 'polluting' the global scope with variables that are intended to be local to the script. Global variables created from a script can produce name collisions with global variables created from another script, which will usually lead to runtime errors or unexpected behavior. It is mostly useful for browser scripts.
Comparing to null
without a type-checking operator (===
or !==
), can have unintended results as the comparison will evaluate to true
when comparing to not just a null
, but also an undefined
value.
In JavaScript, you can extend any object, including builtin or "native" objects. Sometimes people change the behavior of these native objects in ways that break the assumptions made about them in other parts of the code.