Skip to content

Instantly share code, notes, and snippets.

@sudodo
Created January 21, 2012 06:26
Show Gist options
  • Save sudodo/1651697 to your computer and use it in GitHub Desktop.
Save sudodo/1651697 to your computer and use it in GitHub Desktop.
JavaScript module pattern skelton
MYAPP.namespace('MYAPP.utilities.array');
MYAPP.utilities.array = (function () {
// dependencies
var uobj = MYAPP.utilities.object,
ulang = MYAPP.utilities.lang,
// private properties
array_string = "[object Array]", ops = Object.prototype.toString;
// private methods
// ...
// end var
// optionally one-time init procedures
// ...
// public API
return {
inArray: function (needle, haystack) {
for (var i = 0, max = haystack.length; i < max; i += 1) {
if (haystack[i] === needle) {
returan true;
}
}
},
isArray: function (a) {
return ops.call(a) === array_string;
}
// ... more methods and properties
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment