1. Don't know why the above to write a enclosing _init ()?
2. The prototype _init () should be covered above init, js does not support overloaded like?
CodePudding user response:
Enclosing _init () is not defined as calls, he put the following the _init function call
CodePudding user response:
In the new JackTokenizer (), that this is the new new instance, you can call on the prototype chain _init function, so he is called the here
CodePudding user response:
Thank you can add a qq? 1825491283
CodePudding user response:
Do you know the tractor?
The front is the constructor of the object, the back of the car hopper is the prototype of the constructor object, which is the prototype,
When you are new to a JackTokenizer objects, like according to the above drawings made a tractor,
Properties and methods in the constructor will create it again in the object,
When this point is that the new object,
The prototype object prototype is all common constructor created objects,
Call object attributes or methods of a rule is: the first to find whether there is a property or method of object, if there is, to read or call; If does not exist, to share the prototype of the object lookup in the the prototype, if present, read or call; If it does not exist along a prototype to find the prototype object prototype object, (should be a prototype object and object, no doubt, this is the doll)
CodePudding user response:
references a colourful crow 4 floor response: do you know the tractor? The front is the constructor of the object, the back of the car hopper is the prototype of the constructor object, which is the prototype, When you are new to a JackTokenizer objects, like according to the above drawings made a tractor, Properties and methods in the constructor will create it again in the object, When this point is that the new object, The prototype object prototype is all common constructor created objects, Call object attributes or methods of a rule is: the first to find whether there is a property or method of object, if there is, to read or call; If does not exist, to share the prototype of the object lookup in the the prototype, if present, read or call; If it does not exist along a prototype to find the prototype object of a prototype object, (should be a prototype object and object, no doubt, this is the dolls) 1. That is not creating many objects will cause a lot of fight a car with only one car? 2. Jack prototype prototype of how to define? How do doesn't define dolls? CodePudding user response:
The reference cat cat cat cat cat 2 floor? Response: in the new JackTokenizer (), that this is the new new instance, you can call on the prototype chain _init function, so he is called the Elder brother see my reply CodePudding user response:
reference 5 floor qq_29719091 reply: Quote: a colourful crow reference 4 floor response: do you know the tractor? The front is the constructor of the object, the back of the car hopper is the prototype of the constructor object, which is the prototype, When you are new to a JackTokenizer objects, like according to the above drawings made a tractor, Properties and methods in the constructor will create it again in the object, When this point is that the new object, The prototype object prototype is all common constructor created objects, Call object attributes or methods of a rule is: the first to find whether there is a property or method of object, if there is, to read or call; If does not exist, to share the prototype of the object lookup in the the prototype, if present, read or call; If it does not exist along a prototype to find the prototype object of a prototype object, (should be a prototype object and object, no doubt, this is the dolls) 1. That is not creating many objects will cause a lot of fight a car with only one car? 2. Jack prototype prototype of how to define? How do doesn't define dolls? 1. A prototype is going to make a lot of the corresponding instance, it's a bit like a static method 2. The prototype of the prototype was the prototype of the prototype of the class Object, the prototype is the Object class, then define the prototype prototype will define Object. The prototype CodePudding user response:
Reference whenever code read an object of a certain property, will perform a search, the goal is to have the attributes of a given name, search, first of all, from the beginning of the object instance itself, if found in the instance with the given name of the attribute, it returns the value of the attribute. If not found, continued to search the pointer to the prototype of the object, to look for in the prototype object with the given name of the attribute, this property if found in the prototype object, it returns the value of the attribute, that is, as we call person1. SayName (), the search will be executed twice, first of all, the parser will ask: "have sayName attribute instance person1?" A: "no," then, it continues to search, ask: "have sayName attribute person1 prototype?" Answer: "yes," then, it reads the stored in the prototype object function, and when we call person2. SayName (), the search will repeat the same process, get the same results, which is more than one object instance Shared prototype, holds the attributes and methods of the basic principles of - "JavaScript high-level programming (3rd edition)" chapter 6 1. That is not creating many objects will cause a lot of fight a car with only one car? A: Every wrong, but don't imagine the look of the chopped, the fact that the benefits of using a prototype object can let all Shared object instance it contains properties and methods, for example: one of the constructor sayHello () method, so new out of every object contains a sayHello () method, but each object in the sayHello () method is different, they have the independent space in memory, but what they do is the same, if you need 100 of these objects, then there should be 100 in the memory space, a lot of space to repeat things, this is a good developers can't stand, as a result, the prototype object offers a chance for resource sharing, 2. Jack prototype prototype of how to define? How do doesn't define dolls? A: The function Person (age) { this.age=age; } Person. The prototype. Eat=function () { The console. The log (" eat durian ") }; Var per=new Person (10); The console. Dir (per); The console. Dir (Person); Instance objects in __proto__ prototype The constructor has a prototype prototype object Prototype is an object so have __proto__ prototype In the instance objects __proto__ is the prototype of the constructor of a So the prototype __proto__ pointing to a constructor in the prototype prototype Person of the prototype of __proto__ points to: The console. The log (Person) prototype) __proto__);//Object In the instance objects per __proto__ points to is the prototype of the Person, Person __proto__ point to an Object of the prototype of the prototype, The prototype of the Object orientation of __proto__ is null CodePudding user response:
references a colourful crow eighth floor response: reference whenever code read an object of a certain property, will perform a search, the goal is to have the attributes of a given name, search, first of all, from the beginning of the object instance itself, if found in the instance with the given name of the attribute, it returns the value of the attribute. If not found, continued to search the pointer to the prototype of the object, to look for in the prototype object with the given name of the attribute, this property if found in the prototype object, it returns the value of the attribute, that is, as we call person1. SayName (), the search will be executed twice, first of all, the parser will ask: "have sayName attribute instance person1?" A: "no," then, it continues to search, ask: "have sayName attribute person1 prototype?" nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull