JS —— 判断类型
function type (target){ var template = { '[object Array]' : 'array', '[object Object]' : 'object', '[object Number]' : 'number-object', '[object Boolean]' : 'boolean-object', '[object String]' : 'string-object', } if(target === null){ return "null"; }else if(typeof(target) == 'object'){ var set = Object.prototype.toString.call(target); return template[set]; }else{ return typeof(target); } }