Skip to content

Instantly share code, notes, and snippets.

@ernestlv
Last active August 29, 2015 14:27
Show Gist options
  • Save ernestlv/086ee8c2ea0b1450a3fd to your computer and use it in GitHub Desktop.
Save ernestlv/086ee8c2ea0b1450a3fd to your computer and use it in GitHub Desktop.
converts and array like object to an array
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