What is the relationship between _ _ proto__ and prototype in js
This article mainly explains "what is the relationship between _ _ proto__ and prototype in js". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is the relationship between _ _ proto__ and prototype in js"?
Description
1. Each object has a _ _ proto__ attribute to identify the inherited prototype object, but only the function has the prototype attribute.
2. Each function has a prototype property, which is the prototype object of the function.
Inheritance can be achieved by assigning the _ _ proto__ attribute of the instance object to the prototype object prototype,JavaScript whose constructor can be used to create the object.
Example
Function Person () {} Person.prototype.name = "Nicholas"; Person.prototype.age = 29th Person.prototype.job = "Software Engineer"; Person.prototype.sayName = function () {alert (this.name);}; var person1 = new Person (); person1.sayName (); / / "Nicholas" so far, I believe you have a deeper understanding of "what is the relationship between _ _ proto__ and prototype in js". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!