I've been wondering for a long time how jQuery can be both a function and an object property.
You can use it like a function, jQuery(...) and you can use it like a property jQuery.ajax(...)
How can you achieve a such thing in Javascript?
functions are objects in javascript. So you can have your main function
var $ = function() { alert('wat'); }
and then extend it
$.fadeTo = function() { alert('fadeto'); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With