Jump to content

How does JQuery use $?


retro-starr

Recommended Posts

$ is a valid symbol name in JavaScript. Try it!

$ = "blah blah";alert($); // alerts "blah blah"

So the jQuery script just assigns a whole lot of stuff to the variable called $.

Link to comment
Share on other sites

For the record, your definition of jQuery is spot on. A file with nice stuff pre-made for you is what's generally reffered to as a "library". In jQuery's case, that would be a JavaScript library, since the pre-made stuff is JavaScript functions. In, for example, a PHP context, a library could consist of a collection of nice PHP classes, functions and/or constants.A portion or a superset of such a collection that's used for a specific purpose is usually reffered to as API. A library and an API will sometimes overlap. e.g. the GD library in C is exposed to PHP via PHP's GD API. In this case we call PHP's part "API" because it's only an "interface" (a bridge if you will) to the real deal.

Link to comment
Share on other sites

Somehow $ fell through the cracks. All other non-alphanumeric characters on a US keyboard serve a programming purpose of some kind, so they would be misunderstood as variable identifiers.For what it's worth, some popular "evangelists" recommend not using _ at the start of an identifier. It is still technically correct, however.

Link to comment
Share on other sites

It's syntanctically valid, but is not considered good practice exactly because of that blur.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...