Interesting IE JScript support

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freedom9ner
    New Member
    • Aug 2008
    • 3

    Interesting IE JScript support

    Anyone have any insight into why/how this amazingly works? Notice the dot notation in the function name. This will only work in IE. Interesting...

    Code:
    function MyFunction()
    {
    }
    			
    function MyFunction.MyFunction2()
    {
    	alert("worked!");
    }
    			
    MyFunction.MyFunction2(); //works!
    			
    //
    			
    function MyNonExistantFunction.MyFunction3()
    {
    	alert("will not work"); //MyNonExistantFunction not declared first
    }
    			
    MyNonExistantFunction.MyFunction3();
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    this works in all browsers:

    Code:
    function MyFunction()
    {
    }
     
    MyFunction.MyFunction2=function ()
    {
        alert("worked!");
    }
     
    MyFunction.MyFunction2(); //works!

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by rnd me
      this works in all browsers:

      Code:
      function MyFunction()
      {
      }
       
      MyFunction.MyFunction2=function ()
      {
          alert("worked!");
      }
       
      MyFunction.MyFunction2(); //works!
      Is there any difference between MyFunction.MyFu nction2=functio n (){} and function MyFunction.MyFu nction2(){}?

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by freedom9ner
        Anyone have any insight into why/how this amazingly works? Notice the dot notation in the function name. This will only work in IE. Interesting...
        How much you gone through Function ?

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          Originally posted by dmjpro
          Is there any difference between MyFunction.MyFu nction2=functio n (){} and function MyFunction.MyFu nction2(){}?
          yes, though very minor.

          here is an elaboration.

          Comment

          Working...