var a = [1,2,3]; var b = {name:'zhangsan',sex:123}; var fn = function(){}; var detectType = function(o){ if(o instanceofArray){ return'Array' }elseif( o instanceofObject ){ return'Object'; }else{ return'param is no object type'; } } console.log( detectType(a) ); // Array console.log( detectType(b) ); // Object console.log( detectType(1) ); // param is no object type console.log( detectType(true) ); // param is no object type console.log( detectType('a') ); // param is no object type