skip to main | skip to sidebar

Shannon Norrell Webdood Tech

Wednesday, October 6, 2010

Javascript Array Detection

Turns out the most reliable way to detect an Array is not to use the old return (typeof foo === 'object' && foo.constructor === Array) but rather to do this:


function isArray(anArray) {
return Object.prototype.toString.apply(anArray) === "[object Array]";
}
Posted by WebDood at 3:38 PM No comments:
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2014 (1)
    • ►  May (1)
  • ►  2012 (2)
    • ►  July (1)
    • ►  June (1)
  • ►  2011 (3)
    • ►  August (1)
    • ►  March (1)
    • ►  January (1)
  • ▼  2010 (8)
    • ▼  October (1)
      • Javascript Array Detection
    • ►  September (1)
    • ►  August (2)
    • ►  June (1)
    • ►  April (2)
    • ►  March (1)
  • ►  2009 (8)
    • ►  December (1)
    • ►  October (1)
    • ►  September (2)
    • ►  July (1)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
  • ►  2008 (3)
    • ►  September (1)
    • ►  March (2)
  • ►  2007 (20)
    • ►  December (1)
    • ►  October (1)
    • ►  September (5)
    • ►  August (1)
    • ►  July (1)
    • ►  June (8)
    • ►  May (3)

About Me

WebDood
View my complete profile