①if(!document.all&&document.getElementById) 这个(!document.all&&document.getElementById)的document.getElementById代表什么以前都是getElementById()这么用,不加括号代表什么这个条件语句应该怎么理解②if (!("a" in window))
{
var a = 1;
}
alert(a);var a = 1,
b = function a(x)
{
x && a(--x);
};
alert(a);关于这段代码"a" in window这个的意思是a在全局变量中?为什么第一次弹出的a是一个函数?

解决方案 »

  1.   

    document.getElementById方法引用
    document.getElementById("xx")执行此方法
      

  2.   

    "a" in window   是判断  window  对象中  是不是有一个 “a”  的 属性存在,按理说没定义的话应该是不存在的,但是我试了下,每次alert("a" in window)都会为true,不知道什么原因
      

  3.   

    第一次弹出的a是undefined,第二次是1吧。
    怎么第一次是个函数?
      

  4.   

    如果你只写alert("a" in window)这一句应该是返回false的吧?
      

  5.   

    如果你只写alert("a" in window)这一句应该是返回false的吧?我这里第一次弹出的是函数
      

  6.   

    如果你只写alert("a" in window)这一句应该是返回false的吧?我这里第一次弹出的是函数
    你用的什么浏览器啊。。应该是浏览器实现机制不一样吧。。
      

  7.   

    如果你只写alert("a" in window)这一句应该是返回false的吧?我这里第一次弹出的是函数
    你用的什么浏览器啊。。应该是浏览器实现机制不一样吧。。IE8
    第一次弹出
    function a(x)
    {
    x && a(--x);
    };
    第二次弹出1
      

  8.   

    木有IE8,但是IE9和Chrome Maxthon都不是这样的。。
    IE8太与众不同。。
      

  9.   

    不过IE感觉都奇葩。var b=function a(x)
    {
      return x?x*a(x-1):1;
    }
    比如这种形式定义的,貌似只有IE中a才是全局的,Chrome和Maxthon都不能直接访问a。所以可能IE8中第一次会alert说a是下面那个函数。不过话说这是两端分开的代码吧。。LZ怎么硬是要合在一起。。
      

  10.   

    document.getElementById方法引用这是什么意思
      

  11.   

    if(!document.all&&document.getElementById) !document.all如果 document里有一个all对象
    document.getElementById 如果document里有一个getElementById 对象参考代码var a= {};
    alert(a.b);
    a.b=funciton(s){alert(s)};
    alert(a.b);
    alert(a.b("test"));
      

  12.   

    if(!document.all&&document.getElementById) 这个(!document.all&&document.getElementById)的document.getElementById代表什么以前都是getElementById()这么用,不加括号代表什么这个条件语句应该怎么理解Re:
    用来判断运行环境的,因为document.all是IE独有的东东,所以!document.all为真时即表示不是在IE浏览器的环境下
    这里的all和getElementById都是作为属性来使用的,getElementById加了()是当方法来使用了至于第二个问题,估计是因为IE下预编译的问题吧。拎不清,就不误人子弟了
      

  13.   


    funciton 打错 应为function