// 方法一 正则
function reverse(str){
var reg = /\w+/g;
var arr = str.match(reg);
var str = "";
var len = arr.length;
for(var i=len-1;i>0;i++){
str = str+arr[i]+" ";
}
str+=arr[0];
return str;
}
// 方法二 递减循环遍历
String.prototype.split = String.prototype.split || function(target){
var arr = [];
var temp = "";
for (var i=0;i<this.length;i++) {
var ch = this.charAt(i);
if(ch == target){
arr.push(temp);
temp = "";
}else{
temp += ch;
}
}
arr.push(temp);
return arr;
}
function reverse(str){
var arr = str.split(" ");
var newStr = ""
var len = arr.length;
for(var i=len-1;i>0;i++){
newStr = newStr+arr[i]+" ";
}
newStr+=arr[0];
return newStr;
}
千秋此意
qq_包包世界我专业_0
相关分类