87,922
社区成员
发帖
与我相关
我的任务
分享
<script>
alert(typeof []); //typeof 数组是 object
alert([] instanceof Array); // 数组instanceof Array 是true 判断更精确一些
</script>
function fun()
{
if(arguments.length=1)
{
alert(arguments[1]);
}
else if(arguments.length=2)
{
alert(arguments[0]+arguments[1])
}
else
{
alert("有多个参数")
}
}
fun("hello")//输出hello
fun(1,2)//输出3
fun(1,2,"hello")//输出有多个参数
function hey(name){
if(typeof name === "string") alert("string "); //handler string
if(typeof name === "number") alert("number "); //handler number
}
hey(123);
hey("abc");