I believe I got it, using:

jQuery.log = {
  error : function() { ... },
  warning : function() { ... },
  debug : function() { ... },
}; 

as opposed to:

var log = {
  error : function() { ... },
  warning : function() { ... },
  debug : function() { ... },
}; 

prevents a conflict with some other script that uses log in the global
scope. Of course, I still have to watch out for other jQuery.log objects.
thx


Jörn Zaefferer wrote:
> 
> Daniel MacDonald schrieb:
>> It seems the former opens up the door to unintended closures. What are
>> the
>> benefits of doing it this way as opposed to the traditional non-jQuery
>> way?
>>   
> Thats it! By putting everything into a single global object, there isn't 
> the chance of colliding with other libraries or global objects in general.
> 
> Mike answered the other issue :-)
> 
> -- 
> Jörn Zaefferer
> 
> http://bassistance.de
> 
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Advantages-of-adding-functions-to-jQuery-tf3404801.html#a9486114
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to