Skip to content

Instantly share code, notes, and snippets.

@tobie
Created December 11, 2008 02:17
Show Gist options
  • Save tobie/34575 to your computer and use it in GitHub Desktop.
Save tobie/34575 to your computer and use it in GitHub Desktop.
function concat() {
var array = slice.call(this, 0), item;
for (var i = 0, length = arguments.length; i < length; i++) {
item = arguments[i];
if (Object.isArray(item) && !('callee' in item)) {
for (var j = 0, arrayLength = item.length; j < arrayLength; j++)
array.push(item[j]);
} else {
array.push(item);
}
}
return array;
}
// fix for opera
var CONCAT_ARGUMENTS_BUGGY = (function() {
return [].concat(arguments)[0][0] !== 1;
})(1,2)
if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment