Skip to content

Instantly share code, notes, and snippets.

@Sljubura
Created February 16, 2013 11:49
Show Gist options
  • Save Sljubura/4966553 to your computer and use it in GitHub Desktop.
Save Sljubura/4966553 to your computer and use it in GitHub Desktop.
Module pattern with constructor.
// Module pattern that creates constructor function.
APP.utilities.Array = (function (app, global) {
// Dependencies
var uobj = APP.utilities.object,
ulang = APP.utilities.lang,
// Private properties
Constructor;
// Public constructor
Constructor = function (o) {
this.elements = this.toArray(o);
};
// Public API
Constructor.prototype = {
constructor: APP.utilities.Array,
toArray: function (obj) {
for ( var i = 0, a = [], len = obj.length; i < len; i += 1 ) {
a[i] = obj[i];
}
return a;
}
};
return Constructor;
}(APP, this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment