Skip to content

Instantly share code, notes, and snippets.

@daronwolff
Created May 19, 2016 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daronwolff/f9c13de0cfa157810cfdc59b05044030 to your computer and use it in GitHub Desktop.
Save daronwolff/f9c13de0cfa157810cfdc59b05044030 to your computer and use it in GitHub Desktop.
This little script is used to test if an array is really an array or not.
"use strict";
if (Array.prototype.isArray === undefined) {
Array.prototype.isArray = function (value) {
return Object.prototype.toString.apply(value) === "[object Array]";
};
}
/*
Examples
*/
Array.isArray({}); //false
Array.isArray([]); //true
var animals = ["Cat","Dog","Horse"];
Array.isArray(animals); //True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment