JS 类型判断

1
2
3
4
5
6
7
8
9
10
11
/**
* 判断对象类型
* @param [obj: any] 参数对象
* @returns String
*/
function isType(obj: any) {
return Object.prototype.toString
.call(obj)
.replace(/^\[object (.+)\]$/, '$1')
.toLowerCase();
}