I am working on a simple api that creates and manages the creation of some html ( doesn't matter really.. ).
Anyway, this api is wrapped in one of the UMD snippets, which basically receives an anonymous function as one of its arguments:
Take a look at the code for the actual question:
What happens to 'queues' in terms of memory when:
- The initial state turns to "after usage" state?
- If "someUniqueKey1" object is referenced by some anonymous function passed to jQuery ?
Code:
+function( root, factory ) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define( [ 'jquery' ], factory );
} else if ( typeof exports === 'object' ) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory( require( 'jquery' ) );
} else {
// Browser globals (root is window)
root.Alert = factory( jQuery );
}
}( this, function( $ ) {
var queues = {}; // <-- initial state
// after usage state:
queues = {
"someUniqueKey1": { "someProperty": [] },
"someUniqueKey2": { "someProperty": [] },
}
// constructor some here...
// prototyping goes here..
// ....
return alertAPI
}
);
I tried profiling using chrome dev tools, but all I can see is the created instances and what happens when they are removed.