Last active
August 29, 2015 14:27
-
-
Save ernestlv/086ee8c2ea0b1450a3fd to your computer and use it in GitHub Desktop.
converts and array like object to an array
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
var unboundSlice = Array.prototype.slice; | |
var slice = Function.prototype.call.bind(unboundSlice); | |
function listToArray() { | |
return slice(arguments); | |
} | |
function listToArray2() { | |
return Array.prototype.slice.call(arguments); | |
} | |
function listToArray3() { | |
return [].slice.call(arguments); | |
} | |
var arr = listToArray(1, 2, 3); // [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment