On May 5, 5:36 pm, kiusau <kiu...@mac.com> wrote:
> It helps enormously, as well as everything that came before it.  

Glad it helped. Anyone can feel free to paraphrase what I wrote and
wiki it if you wish ;)

> What
> alert($) returns, however, is the following:
> function (selector, context) {
>     return new (jQuery.fn.init)(selector, context);
> }

In some browsers.

> I also
> understand that methods and properties are pretty much treated the
> same by the object in which they are contained.

Yes, methods are always object properties.

> What I do not
> understand is why jQuery.fn.init is not written as jQuery.fn.init()
> where init() is a method of the jQuery.fn prototype object.

First, I do notice that FF alerts what you have written, yet IE does
not. Doesn't matter how they are represented internally, though,
because they are the same thing. In the actual source, the code is:

function( selector, context ) {
  // The jQuery object is actually just the init constructor
'enhanced'
  return new jQuery.fn.init( selector, context );
}

Since
  jQuery.fn.init === (jQuery.fn.init)
then either representation means the same thing.

Now, as for why "init" is a property of the jQuery.fn (aka
jQuery.prototype) object and then its prototype set to jQuery.fn
itself, I don't know. Seems like an odd coding decision to me, but
perhaps there is some reasoning behind it? I would be curious to know.
Separating out the init() method to just a stand-alone constructor
function called jQuery() works fine and would seem cleaner.

Any other questions? :)

Matt Kruse

Reply via email to