Created
February 10, 2011 09:25
-
-
Save Nutrox/820192 to your computer and use it in GitHub Desktop.
JavaScript - Array Cast Utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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