On May 5, 11:54 am, David Meiser <dmei...@gmail.com> wrote:
> There is some credence to this suggestion, but - for anyone who is familiar
> with traditional coding concepts - what you're essentially saying is to go
> out and learn everything about a library before using the library.

The OP was looking to understand how jQuery works, not just use the
API as a black box.

The cited example was:

(function($) {$.fn.METHOD_NAME = function() {FUNCTION_CODE}})
(jQuery);

I guess I would point out a couple of things:

1. jQuery uses $ as a global alias, but jQuery plugins should not
depend on it in case of noConflict(). So code is often written this
way so that $ can be used in anonymous function code to manipulate the
jQuery object, referencing the global jQuery object by passing it as a
parameter.

2. $.fn is the prototype for new jQuery objects, which are created
with every call to $()

That should be enough to understand the above line, since the syntax
is pretty straight-forward.

With a good understanding of javascript, a person should be able to
browser the jquery source and get a good understand of how it works in
about 10 minutes. IMO.

>  I don't
> - for example - need to know anything about the SSL library in order to make
> a call to SSL.  However, I should definitely know about the programming
> language that I'm *making* *that call in*.

Right. If you're calling jQuery methods, you should understand
javascript as much as possible.

> It's the same thing as jQuery.  If you know about javascript and you've used
> it in the past, than treating jQuery as a library within javascript is
> entirely acceptable.  Provided you're not mixing your jQuery calls with more
> traditional javascript calls you'll be okay.

There are different views on this, but I see more and more people
saying that they "write things in jquery", as if that is somehow a
different language than javascript. I think this will eventually cause
problems in development, because there are cases where a person needs
to branch away from jQuery to be more efficient, to do things it
doesn't natively abstract, and sometimes just to write simpler code.
In order to really understand how to use jQuery, when it is not wise,
and how to work around the issues it may present, you need to have a
good understanding of the core language.

Sure, people can be introduced to javascript by using jQuery and
accomplish quite a bit. But IMO, it's always better to understand the
language first, then use jQuery as a layer of abstraction. Or at least
when you reach the point where you need to do more and want to
understand how jQuery is doing what it does, you need to dig into the
core javascript language to really understand what is going on.

Matt Kruse

Reply via email to