Created
February 17, 2016 09:43
-
-
Save think2011/4d1dd891fd8a9b4fc739 to your computer and use it in GitHub Desktop.
递归的方式反转字符串
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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