The first method
var str = "abcdef";
console.log( str.split("").reverse().join("") );
Second method:
var str="abcdef"
var i=str.length;
i=i- 1;
for (var x = i; x >=0; x--)
{
document.write(str.charAt(x));
}
Third method:
<script> <br>function reverse(str) <br>{ <br> if(str.length == 0)return null; <br> var i = str. length; <br> var dstr = ""; <br> while(--i >= 0) <br> { <br> dstr = str.charAt(i); <br> } <br> return dstr; <br>} <br>var str = "abcdef"; <br>str = reverse(str); <br>document.write(str); <br></script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn