Created
February 16, 2013 11:42
-
-
Save Sljubura/4966517 to your computer and use it in GitHub Desktop.
Module pattern
This file contains hidden or 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 | |
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