js取得对象的类名constructor.name

constructor 属性返回对创建此对象的数组函数的引用。

语法

object.constructor

例子

new Array().constructor//ƒ Array() { [native code] }

constructor.name属性返回创建此对象的类名

语法

object.constructor.name

例子

new Array().constructor.name//"Array"
new Uint32Array(2).constructor.name//"Uint32Array"
原文地址:https://www.cnblogs.com/vickylinj/p/11956527.html