Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the default prototype of the js prototype chain

Shulou Source: shulou.com Published: 2022-05-31 10:35:23 09月23日 Update

This article mainly explains "what is the default prototype of the js prototype chain". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the default prototype of the js prototype chain".

1. By default, all reference type values inherit Object, which is also achieved through the prototype chain.

2. The default prototype of all functions is an instance of Object, so the default prototype contains an internal pointer to Object.prototype.

Example

/ / parent constructor function Father () {this.name = "father" this.house = "cottage"} / / prototype method Father.prototype.alertName = function () {console.log (this.name)} / / Child constructor function Children () {this.name = "children"} / / implement inheritance: prototype object of child constructor = instance object of parent constructor Children.prototype = new Father () / / create a subinstance let c = new Children () / / use the method on the Object prototype console.log (c.hasOwnProperty ('name')) / / true thank you for reading The above is the content of "what is the default prototype of js prototype chain". After the study of this article, I believe you have a deeper understanding of what the default prototype of js prototype chain is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Prototypes functions examples learning content objects situations methods that is ideas points pointers articles more knowledge knowledge points articles types follow questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker MySQL Shulou Information Shulou Tech Info