Created
December 23, 2015 09:46
-
-
Save alexander-heimbuch/2b786bc9db628cd8b4f5 to your computer and use it in GitHub Desktop.
Convert Array like Object to Array
This file contains 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
/* | |
* Convert Array like Object to Array | |
* Source: http://xahlee.info/js/js_convert_array-like.html | |
*/ | |
Object.prototype.toArray = function () { | |
return Array.prototype.slice.call(this); | |
} | |
// {0:"a", 1:"b",2:"c", length:3}.toArray() => ['a', 'b', 'c'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment