Understanding the reason for error in this jQuery setup...

Understanding the reason for error in this jQuery setup...

I see a lot of developers use the following technique because it guarantees that $ is being used for jQuery, when the window is ready...

  1. (function($){
  2.   $(window).load(function(){
  3.     myFunction();
  4.   })
  5. })(jQuery);

But why does the code below, generate an error in my console window?...

  1. (function($){
  2.   $(window).load(function(){
  3.     $.myFunction();
  4.   })
  5. })(jQuery);

Line 4 is just a jQuery function, as upose to a function declaration I used above. Why is that reason enough to generate an error in my console window?  

Thanks for helping me understand.

blackhawk






*Break through the ice and never look back*