Created
February 16, 2013 11:49
-
-
Save Sljubura/4966553 to your computer and use it in GitHub Desktop.
Module pattern with constructor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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