What is happening in Crockford's object creation technique?

后端 未结 4 954
长发绾君心
长发绾君心 2020-12-13 01:40

There are only 3 lines of code, and yet I\'m having trouble fully grasping this:

Object.create = function (o) {
    function F() {}
    F.prototype = o;
             


        
4条回答
  •  执念已碎
    2020-12-13 02:02

    Your major misunderstanding here is that F has global scope. It is declared in the body of Object.create and consequently is only in scope within that method block.

提交回复
热议问题