I'll back up even more, to a very-high level, because these concepts
weren't instantly evident to me; once I realized them it helped me to
better conceptualize how and why jQuery works as it does.

$() aka jQuery(), is basically an implementation of the Factory
Pattern, in which one object is responsible for the creation of other
objects. Of course, it also follows the Prototype pattern; given that
JS is a prototypal language and that the $()/jQuery() function extends
itself into the new object that is created.

Another pattern to be found is the Fluent Interface pattern; this is
what gives jQuery its expressive power by way of "chaining". This
pattern is very simple, and yet also very powerful; imagine jQuery
without chaining!

Anyone notice any other design patterns within jQuery?


On May 5, 9:13 am, kiusau <kiu...@mac.com> wrote:
> QUESTION:  I am looking for an article that explains the conceptual
> relationship between jQuery and Javascript.  Can anyone point me in
> the proper direction?
>
> BACKGROUND:  In my quest to understand why some things in my webpage
> work while others do not I found the following, very useful article
> about the YAHOO object, the creation of namespaces, and how to control
> the number of global variables -- namely, through the creation of
> modules that are based on a single object.  jQuery appears to be just
> such an object, on the one hand, but something entirely different on
> the other.
>
> Many days ago when I first started using jQuery someone provided me
> with a formula for creating jQuery methods.  A formula that I have
> dutifully applied over and over again, but I now believe to excess.
> The formula was the following:
>
> (function($) {$.fn.METHOD_NAME = function() {FUNCTION_CODE}})(jQuery);
>
> In my young mind there are important similarities between this
> expression and that outlined in the very useful article written by
> Eric Miraglia (see below) for the creation of a YAHOO namespace and a
> program module.  I would now like to make the connection, if there is
> one, and am asking where is the best place to find out.  Surely this
> connection would help me understand the relationship between jQuery
> and Javascript.
>
> I remember someone in this forum also having said "jQuery IS
> Javascript".  I believe them, but am obviously having difficulty
> understanding in what way.
>
> USEFUL ARTICLE:  http://yuiblog.com/blog/2007/06/12/module-pattern/
>
> Roddy

Reply via email to