javascript riddle: 2 objects that seem identical with respect to constructor, prototype and __proto__ link, behave differently

こ雲淡風輕ζ 提交于 2019-12-02 11:44:46

As the error points out, a is expected to be a function, that is, it must be callable. The new keyword requires a function object that knows how to construct an instance - but a does not. Letting it inherit from Function.prototype (by using __proto__) does not help anything, callability is an intrinsic property of objects.

You are able to call new f(), as f is such a constructor function, being created by the Function constructor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!