Skip to content

Instantly share code, notes, and snippets.

@kflorence
Created April 29, 2011 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kflorence/947623 to your computer and use it in GitHub Desktop.
Save kflorence/947623 to your computer and use it in GitHub Desktop.
isArrayLike
(function( jQuery ) {
// Determines if we can treat an object like an array.
var isArrayLike = function( obj ) {
var length;
// Supports arrays, jQuery objects, nodeLists and HTMLCollections
// Should also support function arguments, but there is no cross-browser way...
return obj && ( obj instanceof jQuery || ( typeof obj === "object" &&
!jQuery.isWindow( obj ) && ( typeof ( length = obj.length ) === "number" &&
( obj.item && ( obj.namedItem || jQuery.isFunction( obj.item ) ) ) ) || jQuery.isArray( obj ) ) );
};
})( jQuery );
@kflorence
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment