UNPKG

453 BJavaScriptView Raw
1export default function objType(obj) {
2 const type = Object.prototype.toString.call(obj).slice(8, -1);
3 if (type === 'Object' && typeof obj[Symbol.iterator] === 'function') {
4 return 'Iterable';
5 }
6 if (type === 'Custom' &&
7 obj.constructor !== Object &&
8 obj instanceof Object) {
9 // For projects implementing objects overriding `.prototype[Symbol.toStringTag]`
10 return 'Object';
11 }
12 return type;
13}