Here you can find the source of roll()
Array.prototype.roll = function() { var rand = randomNumber(this.length); var tem = []; for (var i = rand; i < this.length; i++) { tem.push(this[i]);//w w w .j av a 2s . c o m } for (var i = 0; i < rand; i++) { tem.push(this[i]); } return tem; }
Array.prototype.rotate = (function () { var push = Array.prototype.push, splice = Array.prototype.splice; return function (count) { var len = this.length >>> 0, count = count >> 0; count = ((count % len) + len) % len; push.apply(this, splice.call(this, 0, count)); return this; ...
Array.prototype.rotate = function ( dir ) { var that = this, direction = dir !== "ccw", columns = that[0].length, flat = [], tmp = []; if ( !(that.length) || !columns ) { console.error("incompatible array lengths"); return false; ...
Array.prototype.rotate = function( n ) { this.unshift.apply( this, this.splice( n, this.length ) ) return this;
Array.prototype.rotate = (function(){ var unshift = Array.prototype.unshift, push=Array.prototype.push, splice=Array.prototype.splice; return function(count){ var len=this.length >>>0, count = count >> 0; count = count % len; push.apply(this,splice.call(this,count,len)); ...