Understanding Anti-Patterns in JavaScript
Anti-Patterns: Understanding Anti-Patterns
What exactly is an anti-pattern in application development?
View Answer:
Can you define a JavaScript anti-pattern?
View Answer:
Excessive variable definition in a global context pollutes the global namespace.
Passing strings rather than functions to setTimeout or setInterval causes the internal usage of eval().
Playing with native methods in the Object class prototype (this is a particularly bad anti-pattern).
Using JavaScript inline because it is inflexible.
The usage of document.write when native DOM alternatives, such as document.createElement, are preferable. Over the years, developers have misused document.write. Drawbacks include that it can overwrite the page we're on after the page loads, whereas document.createElement does not. It also doesn't work with XHTML, so using more DOM-friendly techniques like document.createElement is preferable.
Incorrect Use of True and False Evaluation
Naming Customs (Ninja Code)
Changing the DOM in a loop
New Array.prototype.reduce Object
Written with StackEdit.