Difference of public and private functions.

Difference of public and private functions.

Hello there,

I'm an intermediate jQuery user and I want to build my very first (and hopefully useful) plug in. My question is really simple. When should I use a public and when a private function into the plug in code? They both work well, so why we need them both?

  1. ;(function($) {
  2.  //plugin code... 
  3. // Private function
  4. function privateFunc() { };
  5. // Public function
  6. $.fn.plugin.publicFunc = function(){ };
  7.  })(jQuery);

Thanks in advance,
John