js如何判断方法参数是对象还是其他的

 <input id="mc" type="text" value="a"/>
<input name="mc" type="text" value="b"/>
<input name="mc" type="button" onclick="a("+mc+")" value="c">
<script type="text/javascript">
function a(mc){

}
    </script>

js是弱类型语言,你参数传值或者对象都可以,有个函数判断参数类型的,typeof() 希望对你有帮助

 <!DOCTYPE html>
<html>
<body>

<script>
var a1= new Object;
function a(mc){
  /*
1. 'undefined' --- 这个值未定义;
2. 'boolean'    --- 这个值是布尔值;
3. 'string'        --- 这个值是字符串;
4. 'number'     --- 这个值是数值;
5. 'object'       --- 这个值是对象或null;
6. 'function'    --- 这个值是函数。*/
  alert(typeof mc);
}
a(a1);
a(document.getElementById('ipt'));
</script>
<input type='text' id='ipt'/>
</body>
</html>

对象,数组和null
typeof(x) = "object"

$.isArray()

js是弱类型语言,你参数传值或者对象都可以,有个函数判断参数类型的,typeof() 希望对你有帮助

对象,数组和null
typeof(x) = "object"