Adam Lee
Adam Lee

Reputation: 25738

what does $ mean here in JQuery

In the following

var obj = { one:1, two:2, three:3, four:4, five:5 };
    $.each(obj, function(i, val) {
       console.log(val);
    });

what does $ mean here? Is $ an object?

Upvotes: 0

Views: 166

Answers (4)

gray state is coming
gray state is coming

Reputation: 2107

$ is referring to the jQuery function.

In JavaScript, a function is a special kind of object.

You can create a function and add properties to it like any other object.

var $ = function(message) { alert(message); };

$.prop1 = 'val1';
$.prop2 = 'val2';

$("Hello world");

alert($.prop2);

alert($ instanceof Object);   /* This will be "true" */
alert($ instanceof Function); /* This will be "true" */

Upvotes: 0

TyMayn
TyMayn

Reputation: 1936

http://api.jquery.com/jQuery/

jQuery() — which can also be written as $() — searches through the DOM for any elements that match the provided selector and creates a new jQuery object that references these elements..

-jQuery Site

Upvotes: 0

Xion
Xion

Reputation: 22770

$ is an alias for jQuery object/function. It's acts as a namespace under which all jQuery functions are stored.

Upvotes: 5

Adil
Adil

Reputation: 148110

$ stands for jQuery function/object, you can find good discussion over here

Upvotes: 1

Related Questions