What's wrong with a JavaScript class whose constructor returns a function or an object

前端 未结 4 1744
忘掉有多难
忘掉有多难 2021-01-23 23:42

When I use new to instainciate an instance of a certain class, I got the actual instance. When the constructor function has a return value, the new sen

4条回答
  •  心在旅途
    2021-01-24 00:26

    In JS, when we declare a function as a class and when we create an object of that class, that function gets called first.

    Dont return from the function.

提交回复
热议问题