Skip to content

Instantly share code, notes, and snippets.

@Sljubura
Created February 16, 2013 11:42
Show Gist options
  • Save Sljubura/4966517 to your computer and use it in GitHub Desktop.
Save Sljubura/4966517 to your computer and use it in GitHub Desktop.
Module pattern
// Module pattern
APP.utilities.array = (function () {
// Private properties
var array_string = "[object Array]",
ops = Object.prototype.toString(),
// Private methods
inArray = function (haystack, needle) {
for (var i = 0; i < haystack.length; i = i + 1) {
if (haystack[i] === needle) {
return i;
}
}
return -1;
},
isArray = function (e) {
return ops.call(a) === array_string;
};
// Public API
return {
isArray: isArray,
indexOf: inArray
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment