This is extrapolated from the following stackoverflow post: To understand the difference between Module.exports and exports, you have to understand how require() is implemented. First a Module object is created: Then the code from the required file is wrapped in an IIFE to give it function scope As you can see in the IIFE parameter […]
Creates a new object Invokes func with ‘this’ set to the newly created object, passing any arguments along to func (‘arg’ in the above example). Sets the new object’s prototype equal to func’s prototype. Returns the new object Example Property lookup f -> func.prototype -> Object.prototype
I never remember to use this Can be shortened to: Maybe I’ll remember it now…8-)
jQuery 1.5 introduced deferred objects. From the jQuery site: jQuery.Deferred(), introduced in version 1.5, is a chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function. I learned about deferred objects recently when I needed to chain two […]
Use a closure This is an example of how I used a closure to keep the context I wanted while binding an anonymous function to a jQuery UI event.