Constructor concept in javascript

后端 未结 5 1577
终归单人心
终归单人心 2021-02-03 12:33

In one of my questions, I got the following code as one of the answers. My understanding of the language has come has come a far better now, just have one small question.

<
5条回答
  •  我在风中等你
    2021-02-03 13:17

    Any function that is called with new operator acts as a constructor, so this will be assigned to the new object and points to it. Also the code inside the constructor will be executed and the new object (perObj) will get properties.

提交回复
热议问题