tags:

views:

684

answers:

1

The jQuery documentation covers the function jQuery.extend()s twice, giving it different definitions. The first relates to extending the jQuery object itself: http://docs.jquery.com/Core/jQuery.extend#object. The second relates to extend an input argument: http://docs.jquery.com/Utilities/jQuery.extend

Are these two usages of the same function, or are these actually different functions? I presume its the same function, but then I wonder why its documented twice as different functions.

+1  A: 

They do indeed (obviously) point to the same function internally, which checks for the existence of the target parameter. The difference in the documentation reflects the fact that different objects are being extended - there's no way to pass the jQuery object itself as an argument.

From jQuery.extend, (line 578, http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.js):

// extend jQuery itself if only one argument is passed
if ( length == i ) {
 target = this;
 --i;
}
Andy Mikula
alright. I just kept get befuddled looking for the second docs and only finding the first.
Frank Schwieterman
Yeah - the documentation isn't super clear, but being able to poke through the source when needed definitely helps!
Andy Mikula