2020-12-06 Prototype Chain Interview Questions

Clarify the prototype chain of foo and F, find A and B attributes along the prototype chain;

console.log(foo.a)

foo is an object The prototype chain of the object is Object 

foo.a has a on the prototype chain, so the output value a

 

console.log(foo.b)      undefined

There is no F on the prototype chain of foo

 

console.log(F.a)      value a

The prototype chain of F is the function prototype. The function prototype points to the Object prototype.

console.log(F.b)      value b

The prototype chain of F is the function prototype function prototype

 

Guess you like

Origin blog.csdn.net/wanghongpu9305/article/details/110773204