Javascript Array newunshift( arg )
Array.prototype.newunshift = function( arg ){ if( arg != null && arg != undefined && arg != "" && arg != this[ 0 ] && arg != this[ 1 ] ){ //from www . ja v a 2 s .c o m if( this.length > 0 ){ this[ 1 ] = this[ 0 ]; } if( this.length > 1 ){ this.splice( 2, 1 ); } this[ 0 ] = arg; } };