const objType = (obj) => { return Object.prototype.toString.call(obj).match(/\[object (.*)\]/)[1]; }; 因为js 的type of 无法区分数组和对象。