Created
May 19, 2016 23:05
-
-
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.
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
"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