views:

16

answers:

2

Given:

jQuery.extend({
  fooBar: function(){ return 'baz'; }
});

does it modify the base jQuery object? so afterwards you can call jQuery.fooBar(); // 'baz'

There's nothing in the documentation, but that's what the source does as far as I can tell.

+1  A: 

Yes I believe that is correct. Similarly, if you want to be able to call $(somejQueryObject).fooBar(); you can do this

$.fn.fooBar = function() {
    return $.fooBar();
};
fehays
+1  A: 

The behavior is documented right here: http://api.jquery.com/jQuery.extend/

If only one argument is supplied to $.extend(), this means the target argument was omitted. In this case, the jQuery object itself is assumed to be the target. By doing this, we can add new functions to the jQuery namespace. This can be useful for plugin authors wishing to add new methods to JQuery.

Matt Ball
<.< apparently I need to go remember how to read correctly >.>
Rixius