Skip to content

Instantly share code, notes, and snippets.

@cfv1984
Created April 22, 2015 23:44
Show Gist options
  • Save cfv1984/2e3fb261f5df6d757eb8 to your computer and use it in GitHub Desktop.
Save cfv1984/2e3fb261f5df6d757eb8 to your computer and use it in GitHub Desktop.
var cfv = {};
// Original is (C) Andrea Giammarchi - Mit Style License
cfv.Array = (function(){
function extendedArray(length){
if(arguments.length === 1 && typeof length === "number") this.length = -1 < length && length === length << 1 >> 1 ? length : this.push(length);
else if(arguments.length) this.push.apply(this, arguments);
};
function Array(){};
Array.prototype = [];
extendedArray.prototype = new Array;
extendedArray.prototype.length = 0;
extendedArray.prototype.toString = function(){
return this.slice(0).toString();
};
extendedArray.prototype.constructor = extendedArray;
return extendedArray;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment