user840930
user840930

Reputation: 5578

what does $.functionName(); mean in javascript?

I am not familiar with this syntax. What does the $. mean before the function call?

Upvotes: 4

Views: 8659

Answers (5)

Oleg V. Volkov
Oleg V. Volkov

Reputation: 22421

$ - is just an object name, since $ is valid symbol in JavaScript identifiers. This is not some special syntax, just a regular retrieving of 'functionName' property from object and calling it. Some libraries (like jQuery, for example) alias their main object to this short name to make calls take less space.

Upvotes: 1

SadullahCeran
SadullahCeran

Reputation: 2435

Over here $ sign can be replaced with "jQuery " keyword.

$.functionName();

is the same as

jQuery.functionName();

if you are using jQuery framework. If using something else, it may refer to base object as in jQuery.

Upvotes: 3

themhz
themhz

Reputation: 8424

The dollar sign function has become the more-or-less de facto shortcut to document.getElementById().

http://osric.com/chris/accidental-developer/2008/04/the-javascript-dollar-sign-function/ Check this

And is used by Jquery, Mootools or any other javascript frameworks. Even you can make one

This is a small example

function $(obj) {
    return document.getElementById(obj);
}

Upvotes: 2

Dmytro Shevchenko
Dmytro Shevchenko

Reputation: 34581

$ is just a name of some object. It could be jQuery, or Prototype, in case you're using one of these libraries.

So $.functionName() simply stands for calling a function named functionName of the object named $.

Upvotes: 7

Denis Ermolin
Denis Ermolin

Reputation: 5546

This is alias for JQuery object or Prototype or MooTools. Also you can see _. - Underscore.

Upvotes: 0

Related Questions