Constructor concept in javascript

后端 未结 5 1462
终归单人心
终归单人心 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:01

    There are a few ways to define Javascript classes and invoke them with a constructor. But remember that JavaScript is actually classless.

    1. Use a function
    2. The use of Object literals
    3. A singleton using a function

    An excellent article about it can be found here: 3 ways to define a Javascript class

提交回复
热议问题