// -- Standard functions // Array.concat() - Join two arrays if( typeof Array.prototype.concat==='undefined' ) { Array.prototype.concat = function( a ) { for( var i = 0, b = this.copy(); i=0 ) { var a = this.slice(), b = a.splice( i ); a[i] = v; return a.concat( b ); } }; // Array.lastIndexOf( value, begin, strict ) - Return index of the last element that matches value Array.prototype.lastIndexOf = function( v, b, s ) { b = +b || 0; var i = this.length; while(i-->b) { if( this[i]===v || s && this[i]==v ) { return i; } } return -1; }; // Array.random( range ) - Return a random element, optionally up to or from range Array.prototype.random = function( r ) { var i = 0, l = this.length; if( !r ) { r = this.length; } else if( r > 0 ) { r = r % l; } else { i = r; r = l + r % l; } return this[ Math.floor( r * Math.random() - i ) ]; }; // Array.shuffle( deep ) - Randomly interchange elements Array.prototype.shuffle = function( b ) { var i = this.length, j, t; while( i ) { j = Math.floor( ( i-- ) * Math.random() ); t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i]; this[i] = this[j]; this[j] = t; } return this; }; // Array.unique( strict ) - Remove duplicate values Array.prototype.unique = function( b ) { var a = [], i, l = this.length; for( i=0; i