The history of JavaScript
JavaScript (” JS “for short) is a function-first, lightweight, interpreted or just-in-time compiled programming language. Although it is best known as a scripting language for developing Web pages, JavaScript is also used in many non-browser environments. JavaScript is a prototype-based, multi-paradigm dynamic scripting language, and supports object-oriented, imperative, declarative, and functional programming paradigms.
JavaScript was first designed and implemented in 1995 by Brendan Eich of Netscape in the Netscape Navigator browser. Because Netscape worked with Sun, Netscape management wanted it to look like Java, hence the name JavaScript. But in fact its syntactic style is closer to Self and Scheme.
The standard for JavaScript is ECMAScript. As of 2012, all browsers fully support ECMAScript 5.1, with older browsers supporting at least the ECMAScript 3 standard. On 17 June 2015, ECMA International released the sixth edition of ECMAScript, officially known as ECMAScript 2015, but commonly referred to as ECMAScript 6 or ES2015.
Second, the birth of JavaScript
Brendan was called in at the eleventh hour
The company asked to add a scripting function to the browser. What is the language of web scripting? Netscape had two options: one was to take existing languages like Perl, Python, Tcl, Scheme, and so on, and allow them to be embedded directly into web pages; The other is inventing a whole new language.
Enter Brendan Eich, a 34-year-old systems programmer. Netscape hired him in April 1995.
Brendan Eich’s primary interest and interest is functional programming, and netscape recruited him to investigate the possibility of using the Scheme language as a web scripting language. Brendan Eich himself felt the same way, assuming that he would be working primarily with Scheme when he arrived at his new company.
Just a month later, in May 1995, Netscape decided that the web scripting language of the future would have to “look similar enough to Java” but be simpler enough to make it easy for non-professional web authors to learn. This decision effectively excludes non-object-oriented programming languages such as Perl, Python, Tcl, and Scheme.
Brendan Eich was designated as the designer of this “simplified Version of the Java language.”
However, he has no interest in Java at all. He designed Javascript in just 10 days to meet the company’s demands.
So the Javascript language is really a hybrid of the two language styles —- (simplified) functional programming + (simplified) object-oriented programming. This was decided by Brendan Eich (functional programming) and Netscape (object-oriented programming).
10 Design Flaws with JavaScript
1. Not suitable for developing large programs
Javascript has no namespace and is difficult to modularize; There is no specification for how to distribute code across multiple files; Allows for duplicate definitions of functions with the same name, with the latter overwriting the previous, making modular loading difficult.
2. Very small standard libraries
The standard library of functions provided by Javascript is very small, with only a few basic operations and a lot of functionality missing.
3. The null, and undefined
Null is a type of object, meaning that the object is empty. Undefined is a data type, meaning undefined.
4. Global variables are difficult to control
Javascript global variables, visible in all modules; Global variables can be generated inside any function, which increases the complexity of the program.
5. Automatically insert semicolons at the end of lines
All Javascript statements must end with a semicolon. However, if you forget to add a semicolon, the interpreter does not report an error, but automatically adds a semicolon for you.
6. The plus operator
As an operator, the + sign has two meanings. It can represent the sum of numbers or the concatenation of characters.
7. NaN
NaN is a number that indicates that the interpreter has exceeded its limits. It has some very strange properties.
8. Distinction between arrays and objects
Since Javascript arrays are also objects, it can be complicated to tell whether an object is an array or not.
9. = = and = = =
== is used to determine whether two values are equal. When two value types are different, an automatic conversion occurs, and the result is very counterintuitive. Therefore, it is recommended to use the “===” (exact judgment) comparator at all times.
10. Wrapper objects of basic types
Javascript has three basic data types: strings, numbers, and Booleans. They all have constructors that generate string objects, number objects, and Booleans.
The object types that correspond to the base data types are of little use but of great confusion.