Skip to content

Instantly share code, notes, and snippets.

@Nutrox
Created February 10, 2011 09:25
Show Gist options
  • Save Nutrox/820192 to your computer and use it in GitHub Desktop.
Save Nutrox/820192 to your computer and use it in GitHub Desktop.
JavaScript - Array Cast Utility
Array.cast = function( o ) {
return Array.prototype.slice.call( o, o );
}
//
// EXAMPLES
//
function foo() {
// arguments to array
var args = Array.cast(arguments);
}
// node list to array
var nodes = Array.cast(element.childNodes);
// class list to array
var classes = Array.cast(element.classList); // MSIE doesn't know what "classList" is :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment