[removed] Constructing Objects

前端 未结 1 1928
醉话见心
醉话见心 2021-02-12 22:30

I\'m a bit of a javascript noob, but I have a general question that has been bothering me. Lets take an example:

If I hop into a JS console on Chrome, I can easily brows

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-12 22:51

    Any function that is written in JavaScript can be a constructor when called using the new keyword. As you already noticed the function you are dealing with is native, i.e. written in C or C++ (probably C++ since Chrome's JavaScript engine is written in C++, too). Native functions/objects can have specific behaviour such as your case where you cannot use it as a constructor - there's nothing you can do.

    That "function" doesn't even have a .call() method, you you also cannot call it on an object you created before (not that it would be very useful as it wouldn't have the proper [[Prototype]] set)

    0 讨论(0)
提交回复
热议问题