且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

这在JavaScript函数中引用了什么?

更新时间:2023-11-29 09:51:22

It's creating a new object, using Box as its constructor. The value of this in this case (when the function is called with the new keyword) is the new instance being constructed. This new object will inherit from whatever is defined as Box.prototype (the default being Object.prototype).

I said in this case, because in JavaScript the value of this is determined by how the function is called. I recommend reading the MDN page on this for more information.


Note: if this question is supposed to be closed, it should have been as a duplicate. Here are some possible duplicate links that might also help you: