Data types in javascript:
Primitive Type: number, string. Boolean value. (Original value: null,undefined)
Object types: Key-value pairs, arrays, function, global objects (Math,json)
Reserved words:
Abstractbooleanbytecharclassconstdebuggerdoubleenumexportextendsfinalfloatgotoimplementsimportintinterfacelongnativepacka Geprivateprotectedpublicshortstaticsupersynchronizedthrowstransientvolatile
The concept of packaging objects:
The string "AAA". Len string is not an object. However, it is able to invoke its properties. Note that this is only a temporary object. The internal is created with the new String () for temporary.
Primitive types are never mutable, so they can compare their values. However, the object type is variable. Can't compare their values.
JavaScript prototypes and Inheritance:
Each object in JavaScript is associated with another object, which is the __proto__ (prototype object) Note that the prototype object here is not prototype.
Explain this: The prototype here refers to the prototype of an object created by Keywordnew and constructor calls is the prototype property of the constructor.
The __proto__ of the object instance points to the prototype of the object. The __proto__ of the object is empty.
Here is a sample 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 that the object inherits. To illustrate:
Object.getprototypeof (Array) = = = array.__proto__;
Object.getprototypeof () To view prototype inheritance, such as:
Object.getprototypeof (Array.prototype)//Object
Can see that the prototype of the array inherits object, so the array has his method such as totring () and so on.
The ability to get all the objects has a common prototype. It's an object, but object is just a constructor, and if you want to interview him, just use object. Prototype to get.
Like what. Object: Getprototypeof () to see the inheritance of your own definition
function A () {};function B () {}; A.prototype = new B (); object.getprototypeof (A.prototype)//b
Use Object.create () to implement inheritance:
Object.create () accepts a parameter, which is the prototype of the object. In fact, a second parameter is used to describe the familiar features of the narrative, and the source code is based on new () to assign his prototype.
Object.create = function (o) { var F = function () {}; F.prototype = O; return new F (); }; var b=object.create (a);
Object.create () is able to create objects. Of course, you can also create sub-objects of objects, so you can understand
var a = Object.create ({a:1})
Then A has a familiar with a, so that it can be understood as inherited. The assumption is a function. For example, an array is a function object
var MyArray = object.create (Array.prototype)
That myarray has the whole array method.
Myarray.push
Functions that you define yourself
function Acc () {}acc.prototype.dd = 123;var ACCC = Object.create (Acc.prototype). Accc.dd//123
Not finished!
Basic JavaScript Concept Grooming