Is Function really an Object

后端 未结 5 652
不思量自难忘°
不思量自难忘° 2020-12-07 04:15

I am a self taught web developer and am still trying to come to grips with some JavaScript fundamentals. Below are some quotes extracted from Douglas Crockford\'s Good Part

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 04:26

    reference Is every JavaScript Object a function?

    javascript:alert([ window.navigator.userAgent, Object, Function ].join("\n\n") )
    

    displays

    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 
          Ubuntu/10.04 (lucid) Firefox/3.6.3
    
    function Object() {
        [native code]
    }
    
    function Function() {
        [native code]
    }
    

    also

    javascript:alert([ new Object, new Function ].join("\n\n") )
    

    displays

    [object Object]
    
    function anonymous() {  }
    

    and

    javascript:alert([ new new Function ].join("\n\n") )
    

    displays

    [object Object]
    

提交回复
热议问题