Skip to content

Instantly share code, notes, and snippets.

@think2011
Created February 17, 2016 09:43
Show Gist options
  • Save think2011/4d1dd891fd8a9b4fc739 to your computer and use it in GitHub Desktop.
Save think2011/4d1dd891fd8a9b4fc739 to your computer and use it in GitHub Desktop.
递归的方式反转字符串
var s = '123456';
function reverse (s) {
let _s = [...s];
return s ? _s.pop() + reverse(_s.join('')) : '';
}
reverse(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment