In general, the scope chain is for the variable, JS inside a large scope, there are only two scopes, global scope and function internal scope, if function 1 and define the function 2 (usually anonymous function), then there is a scope chain global scope ==> Function 1 scope = = > function 2 scope; Function 1 can directly use global scope variables, function 2 can directly use global scope and function 1 scope variables
The prototype chain is generally used when defining a constructor, which can be thought of as a constructor or a class corresponding to a constructor; the head of the prototype chain is the object class/constructor, if there is a constructor 1.prototype = constructor 2; Then there is a prototype chain; The Object ==> Constructor 1 ==> Constructor 2, the benefit is that the constructor 2 corresponds to the class, you can have the constructor 1 and the properties in object, JS does not correspond to the inheritance of the keyword, so use the prototype chain to simulate the effect of inheritance
Reference:http://zhidao.baidu.com/link?url=esm11qjkumyr0evqa6lilzsaq86_ 0dxuzqrpwdgzbaeif2pmfgawz-cgnngrjxovdqmjzcrpwxjsc9vbv3n8nq
is the JavaScript scope chain linked to the prototype chain?