First of all sorry for the vague title; couldn't think of a more appropriate wording. I'm relatively new to Javascript and web programming in general (although season in .NET desktop programming). I have been looking at the following coding pattern repeatedly in JS, especially with library functions such as jQuery UI:
$("#MyDiv").dialog({ ... });
My question is (thinking like a C# programmer), what is the type of $("#MyDiv")
? How does dialog()
become a member of this type? I can see that dialog()
is defined in jQuery UI library and can be dynamically attached to any object. What's the magic here? What's C# equivalent of this; Extension methods?
Also, is there a way to get reference of the calling object inside this "attached" function?