A few previous articles, I often said that JavaScript design is not rigorous, there are many mistakes.
Today, the first half of this article talks about why this is the case, and the second half enumerates 10 design flaws in JavaScript.
My reference is mainly in Douglas Crockford's monograph "The JavaScript Language pristine" (javascript:the good Parts) and Fredrik Holmstrm's article "My Complaints about JavaScript" (my Gripes with Javascript).
Why is there a design flaw in JavaScript?
There are three objective reasons why JavaScript design is not perfect.
1. The design phase is too hasty
The design of JavaScript in fact only took 10 days. Moreover, the designer is in order to the company, I do not want to design (see "The Birth of JavaScript").
On the other hand, this language is designed to solve some simple web interaction (for example, check "username" to fill in), and does not consider the needs of complex applications. The designer never dreamed that JavaScript could write a huge and complex web page like Gmail in the future.
2. There is no precedent
JavaScript combines functional programming with object-oriented programming, which is probably the first case in history. And until today, JavaScript is still the only major language in the world to use the prototype inheritance model. This makes it less of a design precedent to refer to.
3. Premature standardization
JavaScript is developing very fast and there is no time to adjust the design.
May 1995, the design was finalized, October, the interpreter successfully developed, December, launched to the market, is immediately widely accepted, the world's users a large number of use. JavaScript lacks a small to large, slowly accumulate the user's process, but the continuous explosion of proliferation growth. The extensive participation of both web and amateur web designers makes it difficult to adjust language specifications.
To make it worse, the JavaScript specification has not yet been adjusted and is cured.
In August 1996, Microsoft had a strong intervention to announce its own scripting language jscript;11 months, in order to suppress Microsoft, Netscape decided to apply for JavaScript international standards, June 1997, the first international standard ECMA-262 officially promulgated.
In other words, after the introduction of JavaScript 1.5, international standards came out. Design flaws have not been fully exposed and become standard. By contrast, almost 20 years after the advent of the C language, international standards were promulgated.