A statement in advance:
There are three statement ahead of the process: create, initialize, assign:
the console.log (X); // undefined function XXX () {}; var X = 10 ; // equivalent var X = undefined; // create and initialize function XXX () {}; X = 10; // Assignment
But let not only create assignments:
the console.log (X); // given the let X = 10 ; function XXX () {}; // equivalent to the let X; function XXX () {};
Second, prototype
Usually we will create an object like this:
var Plane=function(){ this.name='plane'; } var plane=new Plane(); plane.name='plane1';
Apart outer example by a new, can also be cloned by:
var plane2=Object.create(plane);
Each object we encounter in JavaScript, actually comes from Object.prototype clone objects, Object.prototype is their prototype. To create an object with the new operator process, in fact, only the object to clone Object.prototype, then some other additional operation process.
JavaScript to object provides __proto__, __proto__ default attribute of an object will point to the prototype object to its constructor:
function Animal(name){ this.name=name; } var dog=new Animal(); console.log(dog.__proto__===Animal.prototype); // true
Third, the static method
Din Tai defined by static methods, static methods can be called directly:
Animal {class spaeak () { return the this ; } static EAT () { return the this ; } } Animal.speak (); // error Animal.eat (); // Direct call