1 | ;
|
2 |
|
3 | /**
|
4 | * 获取数据类型
|
5 | *
|
6 | * @param {any} obj 需要获取类型的数据
|
7 | * @returns {string} number|string|array|date|object|boolean|regExp|function|null|undefined
|
8 | */
|
9 | let fun = (obj)=>{
|
10 | let sType;
|
11 | try {
|
12 | let objType = obj.constructor.name;
|
13 | sType = objType.substr(0,1).toLowerCase() + objType.substr(1);
|
14 | } catch (err) {
|
15 | sType = obj+''.toLowerCase();
|
16 | };
|
17 | return sType;
|
18 | };
|
19 |
|
20 | module.exports = fun; |
\ | No newline at end of file |