Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created March 30, 2009 22:19
Show Gist options
  • Select an option

  • Save ibolmo/87914 to your computer and use it in GitHub Desktop.

Select an option

Save ibolmo/87914 to your computer and use it in GitHub Desktop.
function $A(iterable){
if (iterable.item){
var array = [];
for (var i = 0, l = iterable.length; i < l; i++) array[i] = iterable[i];
return array;
}
return Array.prototype.slice.call(iterable);
};
function $A(iterable){
if (iterable.item){
var array = [], l = iterable.length;
while(l--) array[l] = iterable[l];
return array;
}
return Array.prototype.slice.call(iterable);
};
function $A(iterable){
if (iterable.item){
var l = iterable.length, array = new Array(l);
while(l--) array[l] = iterable[l];
return array;
}
return Array.prototype.slice.call(iterable);
};
function $A(iterable){
if (!iterable.item) return Array.prototype.slice.call(iterable);
var l = iterable.length, array = new Array(l);
while (l--) array[l] = iterable[l];
return array;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment