HuyPV
Wednesday, October 14, 2009
String.prototype.reverse1 = function(){
return this.split("").reverse().join("");
}
String.prototype.reverse2 = function(){
var i, j=0, reversed = "";
var ttmp=new Array();
for (i = this.length-1; i >= 0; i--) {
ttmp[j++] = this.charAt(i);
}
return ttmp.join("");
}
String.prototype.reverse3 = function(){
var i, reversed = "";
for (i = this.length-1; i >= 0; i--) {
reversed += this.charAt (i);
}
return reversed;
}
Title:
Reverse string in javascript
Description:
String.prototype.reverse1 = function(){ return this.split("").reverse().join(""); } String.prototype.reverse2 = func...
...
Rating:
4