1. The design phase is too hasty
JavaScript design, in fact, only took 10 days. Moreover, the designer is for the company, I do not want to design (see the birth of JavaScript).
On the other hand, the language was designed to solve some simple web interactions (for example, checking whether the "username" was filled out), and did not consider the need for complex applications. Designers never dreamed that JavaScript would be able to write a very large and complex web page like Gmail in the future.
2. No precedent
JavaScript combines both functional programming and object-oriented programming, which is probably the first example of history. And until today, JavaScript remains the only major language in the world that uses the prototype inheritance model. This makes it not possible to design precedents for reference.
3. Premature standardization
JavaScript is developing very quickly and there is no time to adjust the design at all.
In May 1995, the design was finalized; in October, the interpreter was developed successfully; December, to market, immediately widely accepted, the world's users are heavily used. JavaScript lacks a process of small-to-large, slowly accumulating users, but a continuous explosion of proliferation growth. The involvement of a large number of both web and amateur web designers makes it difficult to adjust language specifications.
To make things worse, JavaScript's specs haven't come and been adjusted, and they're cured.
In August 1996, Microsoft's strong involvement, announced 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 formally promulgated.
In other words, when JavaScript launches 1.5, international standards come into existence. Design flaws have not yet been sufficiently exposed to become standard. By contrast, international standards were enacted almost 20 years after the advent of the C language.
10 design flaws in JavaScript
1. Not suitable for developing large programs
JavaScript does not have namespaces (namespace), it is difficult to modularize, there is no specification for how to distribute code across multiple files, a duplicate definition of a function with the same name is allowed, and subsequent definitions can overwrite the previous definition, which is not conducive to modular loading.
2. Very small standard library
JavaScript provides a very small library of standard functions, only a few basic operations, and many features are not available.
3. The meaning of null and undefined is ambiguous
Null belongs to one of the objects (object), meaning that the object is empty; Undefined is a data type, which means undefined.
4. Global variables are difficult to control
5. Automatic insertion of end-of-line semicolon
All the statements of JavaScript must end with a semicolon. However, if you forget to add a semicolon, the interpreter does not give an error, but instead automatically adds a semicolon to you. Sometimes, this can lead to some hard-to-find errors.
6. Plus operator
The + sign, as an operator, has two meanings, can represent numbers and numbers, and can also represent the connection of characters to characters.
7. NaN
Nan is a number that exceeds the limits of the interpreter.
It has some very strange features:
// false // true 1 // NaN
Rather than the design of Nan, the interpreter directly error, but it helps to simplify the program.
8. The distinction between arrays and objects
Since JavaScript arrays also belong to Objects (object), it is quite cumbersome to distinguish whether an object is an array or not.
9. = = and = = =
= = is used to determine whether two values are equal. When the two value types are different, automatic conversions occur, and the resulting results are very counterintuitive.
10. Basic types of Packaging objects
JavaScript has three basic data types: string, numeric, and Boolean. They all have corresponding constructors that can generate string objects, numeric objects, and Boolean objects.
The type of object that corresponds to the base data type is very small, and the confusion is large.
typeof 1234 // Number typeof New Number (1234// Object
JavaScript is a flawed language that relies on strong technology, specifications or a mixture of the two to effectively use it, meaning that most of JavaScript's flaws can be avoided if good programming practices and third-party library help are adhered to.
Why JavaScript has design flaws