Posted on 02-28-2008 under Code, JavaScript

Simple way to determine if a variable is an array. It should be noted: This function doesn’t work in older browsers that don’t support array.push — this function will always return false.

  1.  
  2. function is_array(o) {
  3.         if(o != null && typeof o == ‘object’) {
  4.                 return (typeof o.push == ‘undefined’) ? false : true;
  5.         }else {
  6.                 return false;
  7.         }
  8. }
  9.