How to get a JavaScript object's class?

前端 未结 18 2332
一生所求
一生所求 2020-11-22 15:44

I created a JavaScript object, but how I can determine the class of that object?

I want something similar to Java\'s .getClass() method.

18条回答
  •  温柔的废话
    2020-11-22 16:12

    In javascript, there are no classes, but I think that you want the constructor name and obj.constructor.toString() will tell you what you need.

提交回复
热议问题