The concept of "primitivetypes" ECMAScript (V3, V5) does not have a medium-pressure root. It only divides the root type into six types, if you are interested, you can refer to one of the frequently asked questions in front-end interviews: "What are the basic types of JavaScript? ".
Some answer "numbers, strings, and Boolean", and some may add "Null, Undefined ". Some people may think that "object" is also the basic type. What is it like?
The concept of "primitive types" ECMAScript (V3, V5) does not have a medium pressure root. It only divides the type into six types.
ECMAScript only mentions the type, which is represented by types. In V3 and V5, the entire document does not search for the keyword "primitive" and does not see "primitive type". "primitive value" does, such as true/false/0-9. This indicates that there is no such thing as "basic type" or "primitive type ). If there are objects, there are six basic types.
Some books often use this concept, such as the first, second, and third editions of JavaScript advanced programming.
The first version mentioned five primitive types: Undefined, Null, Boolean, Number, and String.
The second and third editions create a simple data type, which is translated into a simple data type (also known as a basic data type) and called an object as a complex data type.
Another classic book, The JavaScript authoritative guide (version 6th), also mentions primitive types.
It is divided into the basic type (primitive types) and object type, the basic type is divided into numbers, strings, Boolean, and two special null, undefined.
There were few JavaScript books five years ago. These two books are two of them, which have a great impact and can be described as a classic. Therefore, there are a few JSer affected. I think the authors of this book divide the language types into basic types (meta-types) and object types (complex types), which are also in line with the Learning logic. complex types are composed of simple types. It is also affected by other languages such as Java. They also divide types into basic types (8 types) and object types.
However, ECMAScript does not have the so-called primitive types, just like it does not have the class concept (people with other language abilities still like to use the term "class" in JavaScript "). It refers to the type, which can be understood as the basic type, but should also be six. The basic types here are not the basic types in Java, because they contain complex data types-objects.
Not all books hold that there are only five basic types (excluding objects) in JavaScript, and six types are considered as follows:
It does not classify null as one, but adds the function type. Oh, there are all strange answers. How can someone ask this question next time?