javascript - 为什么这段代码执行会返回undefined
PHP中文网
PHP中文网 2017-04-10 15:06:06
0
3
233
var x=[1,2,3];
var y=[2,3,5,6];
alert(typeof((function(){if(x.length>y.length) return y})()));

想不通为什么

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
小葫芦

条件不对哦

typeof((function(){if(x.length<y.length) return y})())
"object"
刘奇

你把后面的()去掉就会返回function

你这样肯定会返回undefined,没意义。

Peter_Zhu
var x=[1,2,3];
var y=[2,3,5,6];
alert(typeof((function(){
  if(x.length > y.length){
    return y;
  }
  return undefined;
})()));

代码写这么乱,自己为难自己么?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template