Data Types in javascript:
Original Type: Number, String, Boolean value. (Original value: null, undefined)
Object Type: Key-value pair, array, function, Global Object (MATH, JSON)
Concepts of packaging objects:
The String "aaa". len is not an object, but can call its attributes. This indicates that this is only a temporary object, which is created using new String () internally.
The original type is always unchangeable, so their values can be compared, but the object type is variable and their values cannot be compared.
Javascript prototype and inheritance:
Every object in Javascript is associated with another object. This object is _ proto _ (prototype object). Note that the prototype object here is not prototype.
Here, prototype refers to the prototype attribute of the constructor, which is the prototype attribute of the object created by the keyword new and constructor call.
The _ proto _ of the object instance points to the prototype of the object, while the _ proto _ of the object is null. For example:
var array = new Array();array.__proto__ === Array.prororype //trueArray.__proro //null
Of course, you can also use Object. getPrototypeOf () instead of _ proto _ to get the prototype inherited by the Object. For example:
Object.getPrototypeOf(Array) === Array.__proto__;
Object. getPrototypeOf () to view prototype inheritance, for example:
Object.getPrototypeOf(Array.prototype) // Object
We can see that the prototype of Array inherits the Object, so Array also has its own method, such as totring. We can see that all objects share a common prototype, that is, the Object is only a constructor. To access the Object, we only use Object... prototype.
For example, Object .. getPrototypeOf () is used to view custom inheritance.
function A(){};function B(){};A.prototype = new B();Object.getPrototypeOf(A.prototype) //B