What are the points for attention of JavaScript prototype chain inheritance
Editor to share with you what are the points for attention of JavaScript prototype chain inheritance, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Reference attribute problem, add reference value attribute to the prototype object, although we usually put the property in the constructor, it will appear in the prototype inheritance.
2. A subclass cannot pass parameters to the constructor of the parent class when instantiating.
Example
Function A () {this.arrs=; function B () {} B.prototype = new A (); let C1 = new B (); let c2 = new B (); console.log (c1.arrs); / / [1m 2m 3] console.log (c2.arrs); / / [1m 2m 3] c1.arrs.push (4); console.log (c1.arrs); / / [1m 2m 3J 4] console.log (c2.arrs) / / [1, 2, 3, 4] the above are all the contents of the article "what are the points for attention in the inheritance of JavaScript prototype chain". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!