Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 5
    @Vitimtk A prototype acts as a fallback for the actual object, so this should work even if the array in question already existed. It won't work before the source line is processed, of course. Commented Dec 28, 2011 at 19:39
  • 38
    Assuming no one does Object.prototype.isArray = true;! :( Commented Sep 30, 2012 at 3:08
  • 14
    Note that in ES5 Array.isArray is a method (e.g., Array.isArray([1,2,3]) === true) so @ErikE wasn't being a troll. I would avoid following this answer as it will break code in some modern browsers. Commented Jul 11, 2013 at 14:00
  • 4
    @Ibu and you can do {}.isArray === true with my "solution", which was the whole point... Commented Jul 12, 2013 at 4:47
  • 2
    Modifying the prototype of Data Types is a bad practice in my opinion Commented Sep 24, 2014 at 4:21