Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the type of jQuery a javascript Object, Function, or Method?

I have used jQuery for a while and understand the basics of selectors and chains. I am now ready to dive into advanced javascript concepts. Now I'm confused with multi-roles of jQuery.

For example,

jQuery.add(...) 

This seems to me that jQuery is a javascript Object that we can send a message to.

jQuery(function() {...}) or jQuery(...selector...)

This time, jQuery seems to be a javascript Function that can take some parameters.

What is it exactly?

like image 602
Nimit Pattanasri Avatar asked Apr 28 '26 23:04

Nimit Pattanasri


1 Answers

console.log(typeof jQuery); outputs '> function' :)

Also try this:

var some_name = function() { return 42; };
some_name.some_property = 84;
some_name.some_method = function() { return 63; };

typeof some_name; // outputs "function"

// but... 
some_name.some_method(); // ...is also possible :)
like image 143
meeDamian Avatar answered Apr 30 '26 13:04

meeDamian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!