话不多说直接上源码
function reverseStr (str) {
return str.match(/[^\s]+/g).join(' ');
}
console.log(reverseStr("this is my way"))//this is my way
实现的思路
通过正则表达式捕获所有的非空的数据存到数组中,然后
话不多说直接上源码
function reverseStr (str) {
return str.match(/[^\s]+/g).join(' ');
}
console.log(reverseStr("this is my way"))//this is my way
实现的思路
通过正则表达式捕获所有的非空的数据存到数组中,然后