参考文章: http://www.kuitao8.com/20140511/2418.shtml
function objType(obj) {
//var type = Object.prototype.toString.call(obj);
// 简写
var type = toString.call(obj);
// array:type = [object Array]
// obj: type = [object object]
// arguments: type = [object arguments]
// string: type = [object String]
// number: type = [object Number]
// boolean: type = [object Boolean]
// function: type = [object Function]
// undefined: type = [object Undefined]
return type ? type.substring(8,type.length-1) : '';
}function isArray(obj){
var type = objType(obj);
return type && type === 'Array' ? true : false;
}
console.log(objType([])); // Array
console.log(objType({})); // Object
console.log(isArray({})); // false
console.log(isArray([])); // true