What is the difference between
var createControl = function (attribute){ ...}
and
$.fn.createControl = function (attribute) { .. }
in jQuery. What is the advantage of changing a function from $.fn.createControl to var createControl.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assigns a function to
foo.Extends the prototype of jQuery with
foo.fnis just a shortcut toprototypeand$is a shortcut forjQuery. You could write the same thing as:The difference is that the former is just a variable within a certain scope, invisible outside of it. The later is a method extending the jQuery global object, thus making the variable accessible from anywhere since the jQuery object is attached to
window, is global.