theblog

Javascript TypeOf with Array Support


function typeOf(obj) {
  if ( typeof(obj) == 'object' )
    if (obj.length)
      return 'array';
    else
      return 'object';
    } else
  return typeof(obj);
}

Just in case someone else was needing the ability to discern the difference between objects, arrays, and other data types in Javascript.