且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript接受单个参数作为字符串并返回一个字符串

更新时间:2022-11-11 10:51:25

尝试以下操作:

Try this:

var str = 'hi how are you';

var reversedStr = str.split("").reverse().join("");



我在Chrome JavaScript控制台中对此进行了测试.效果很好.

注意:如果是请告诉我紧急"这类问题,则可以用Google搜索"javascript反向字符串"并在10秒内找到答案.



I tested this in my Chrome JavaScript console. works fine.

Note: If it was ''please tell me urgent'' kind of question, you could have Googled ''javascript reverse string'' and found the answer within 10 seconds.