Skip to content

Instantly share code, notes, and snippets.

@vestige
Created October 23, 2012 13:18
Show Gist options
  • Select an option

  • Save vestige/3938681 to your computer and use it in GitHub Desktop.

Select an option

Save vestige/3938681 to your computer and use it in GitHub Desktop.
541.js
MYAPP.utilities.array = (function () {
var array_string = "[object Array]",
ops = Object.prototype.toString,
inArray = function (haystack, needle) {
for (var i = 0, max = haystack.length; i < max; i += 1) {
if (haystack[i] === needle) {
return i;
}
}
return -1;
},
isArray = function (a) {
return ops.call(a) === array_string;
};
return {
isArray: isArray,
indexOf: inArray
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment