JS逆轉(zhuǎn)字符串
var str = "doogyrevsig"document.write("
第一種方法:
" + "");document.write("
逆轉(zhuǎn)前:
" + str + "");document.write("
逆轉(zhuǎn)后:
");document.write(str.charAt(10));document.write(str.charAt(9));document.write(str.charAt(8));document.write(str.charAt(7));document.write(str.charAt(6));document.write(str.charAt(5));document.write(str.charAt(4));document.write(str.charAt(3));document.write(str.charAt(2));document.write(str.charAt(1));document.write(str.charAt(0));var str = "doogyrevsig"document.write("第二種方法:
" + "");document.write("
逆轉(zhuǎn)前:
" + str + "");document.write("
逆轉(zhuǎn)后:
");var i=str.length; for ( i ; i >= 0 ; --i ) { document.write(str.charAt(i)); } var str = "doogyrevsig"document.write("第三種方法:
" + "");document.write("
逆轉(zhuǎn)前:
" + str + "");document.write("