Analysis of the relationship between Function, Object, and Prototype

Premise: All built-in objects in js are instances of Function. 

  For example: Array\String\Number... etc.

 

Principle analysis:

  The principle of object property search is to search according to the __proto__ property of the object until __proto__=null stops the search

 1 > Array.__proto__
 2 < function () {}
 3 
 4 >var arr =[]
 5 >arr.__proto__==Array.prototype
 6 <true
 7 
 8 >Function.prototype
 9 <function () {}
10 
11 >Function.__proto__
12 <function () {}
13 
14 >Function.__proto__.__proto__
15 <Object {}
16 
17 >Function.__proto__.__proto__==Object.prototype
18 <true

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325167730&siteId=291194637