Understanding scope, scope chain, prototype, and prototype chain

Scope

The set of accessible variables is called a scope. The scope is divided into global scope and local scope (function scope). Local variables can only be accessed inside the function.

scope chain

Before a function is executed, an execution context object will be created, and the collection of execution contexts stored in the scope is linked in a chain, which we call a scope chain.

prototype

Functions have a prototype attribute, which points to an object, which is called the prototype object, that is, the prototype

prototype chain

Each object can have a prototype __proto__, which can also have its own prototype, and so on, forming a prototype chain

Guess you like

Origin blog.csdn.net/qq_42676363/article/details/103264126