Mike
Mike

Reputation: 3418

What is the difference between these two word in jQuery

I am trying to get the version of jQuery a page is using in an alert. It works perfect:

I use alert(jQuery.prototype.jquery)

Now my question is what is the difference between jQuery and jquery words here that are specified before and after prototype.

which one is specified by $.

Upvotes: 3

Views: 284

Answers (3)

Bergi
Bergi

Reputation: 664936

The global $ and jQuery variables just point to the same function object, they are "aliases". jquery is just the name of the property of the prototype object. The two names have nothing to do with each other - they are names of different properties on different objects.

Upvotes: 2

Dan Herbert
Dan Herbert

Reputation: 103497

The $ is the same as jQuery with a capital 'Q'. The lowercase jquery only represents the version number.

It is more commonly written as jQuery.fn.jquery or as a property of a constructed jQuery object like jQuery('div').jquery.

Upvotes: 3

Hacknightly
Hacknightly

Reputation: 5154

The first is specified by "$", the second is meant to return the jquery version number.

In Chrome console ->

jQuery >>> function (a,b){return new e.fn.init(a,b,h)}

$ >>> function (a,b){return new e.fn.init(a,b,h)}

jQuery.prototype.jquery >>> "1.7.1"

Perhaps it would help to note that JavaScript is case sensitive, so jQuery and jquery are two different variables.

Upvotes: 7

Related Questions