Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - object and function at same time?

I'm just developing my own mini framework for an application I was working on, and I've been studying the jQuery is coded.

I get the way $(selector).function() works, but how come you can call some functions such as:

$.ajax()

Surely this would been the dollar symbol references both a function and the jquery.fn object at the same time?

Thanks in advance!

like image 290
jleck Avatar asked Jun 18 '12 18:06

jleck


1 Answers

Functions are objects in JavaScript so they can have properties.

$ is the jQuery object, when using $() it is used as a constructor (it contains some magic so new is not necessary); but it also contains lots of methods (and some non-callable properties such as $.browser) available as $.something

like image 166
ThiefMaster Avatar answered Oct 20 '22 02:10

ThiefMaster