Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 6x 6x 1x 5x 5x | export function type(x) {
const t = typeof x;
if(x === null){
return 'null';
}
Eif (t !== 'object') {
return t;
}
const toString = Object.prototype.toString;
const innerType = toString.call(x).slice(8, -1);
const innerLowType = cls.toLowerCase();
// 区分 String() 和 new String()
if (['String', 'Boolean', 'Number'].includes(innerType)) {
return innerType;
}
// function A() {}; new A
if (typeof x?.constructor?.name === 'string') {
return x.constructor.name;
}
return innerLowType;
} |