Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to apply the JavaScript member lookup mechanism

Shulou Source: shulou.com Published: 2022-05-31 12:40:46 10月25日 Update

Most people do not understand the knowledge points of this article "how to apply the JavaScript member search mechanism", so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "JavaScript member search mechanism how to apply" article.

Description

1. When accessing the properties of an object (including methods), first investigate whether the object itself has the property.

2. If not, find the prototype (that is, the prototype prototype object pointed to by _ proto__).

3. If you haven't already found the prototype of the prototype object (the prototype object of Object).

4. And so on until Object is found.

Example

Function Star (uname, age) {this.uname = uname; this.age = age;} Star.prototype.sing = function () {console.log ('I can sing');} Star.prototype.sex = 'female'; / / Object.prototype.sex = 'male'; var ldh = new Star ('Andy Lau', 18) Ldh.sex = 'male'; console.log (ldh.sex); console.log (Object.prototype); console.log (ldh); console.log (Star.prototype); console.log (ldh.toString ()) The above is about the content of this article on "how to apply the JavaScript member search mechanism". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Content prototypes objects members mechanisms applications attributes articles knowledge articles and so on value most examples that is directions methods more steps knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple OPPO Reno Shulou Tech Info Redmi