What is JavaScript?

JavaScript (often abbreviated JS) is a high-level, interpreted programming language. JavaScript is a prototype-based, function-first language. It is a multi-paradigm language that supports object-oriented programming, imperative programming, and functional programming. It provides syntax to manipulate text, arrays, dates, regular expressions, etc. It does not support I/O, such as networking, storage, graphics, etc., but these can be supported by its host environment. It has been standardized by ECMA (European Computer Manufacturers Association) through ECMAScript. It is used by the vast majority of the world’s websites and is supported by the world’s major browsers (Chrome, Internet Explorer, Firefox, Safari, Opera).

The birth of JavaScript

It was created in 1995 to handle what is now known as “front-end validation,” meaning that before JavaScript was invented, form item validation had to be submitted to the server, which was a terrible user experience on the web at the time. However, Netscape, the company that invented the browser, decided to develop a language to solve this problem, and there was LiveScript, which was the precursor to JS, because Netscape was co-developing it with Sun, and Netscape wanted to capitalize on the popularity of Java at the time. So they simply changed the name to JavaScript, and the language came to the world’s attention.

However, Microsoft, the Nemesis of Netscape, could not sit still. If you use JavaScript, I will use JScript. , functions in line with JavaScript, so this leads to non-standard JS. However, standardizing JS is on the agenda. In 1997, JavaScript 1.1 was handed over as a blueprint to the European Computer Manufacturers Association, whose technical committee developed the standard, known as ECMA-262. There are now seven versions of it (ES8 is said to be coming soon, ho ho), known as ES5. ES6 and so on.

10 Design Flaws with Javascript

  1. Not suitable for 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. A very small standard library: Javascript provides a very small standard library of functions that do only a few basic things and do not have many features.
  3. Null and undefined: Null is a type of object, meaning that the object is empty. Undefined is a data type, meaning undefined.
   // The two are very confusing, but have completely different meanings.
 typeof null; // object
 typeof undefined; // undefined
Copy the code
  1. Global variables are difficult to control :Javascript global variables are visible in all modules; Global variables can be generated inside any function, which greatly increases the complexity of the program.
  2. Automatic insertion of semicolons: 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. Sometimes, this leads to errors that are hard to spot.
  3. The plus operator: As an operator, the + sign has two meanings. It can represent the sum of numbers or the concatenation of characters.
  4. NaN: NaN is a number that indicates that the interpreter has exceeded its limits. It has some very strange properties:
  5. The distinction between arrays and objects: Since Javascript arrays are objects, it can be tricky to tell whether an object is an array or not.
  6. == and === : == are used to determine whether two values are equal. When two value types are different, an automatic conversion occurs, and the result is very counterintuitive.
  7. Wrapper objects of primitive types: Javascript has three basic data types: strings, numbers, and Booleans. They all have constructors that generate string objects, number objects, and Booleans.

Why is Javascript design flawed

  • The design phase was too hasty, because the Javascript was designed in ten days.
  • Without precedent, Javascript remains the only major language in the world that uses the Prototype inheritance model. This leaves it with no design precedent to follow.
  • Early standardized Javascript moves so fast that there is no time to tweak the design.

The above information comes from: Ruan Yifeng blog