Skip to content

Instantly share code, notes, and snippets.

@fabiomcosta
Created September 20, 2009 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fabiomcosta/189825 to your computer and use it in GitHub Desktop.
Save fabiomcosta/189825 to your computer and use it in GitHub Desktop.
Array.from = function(item, slice){
if(!item) return [];
if(!Type.isEnumerable(item)) return [item];
slice = slice || 0;
try{
return Array.prototype.slice.call(item, slice);
}
catch(e){
var l = item.length, array = new Array(l), i = slice;
for(; i < l; i++) array[i] = item[i];
return array;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment