Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created August 27, 2013 07:22
Show Gist options
  • Select an option

  • Save jswhisperer/6350608 to your computer and use it in GitHub Desktop.

Select an option

Save jswhisperer/6350608 to your computer and use it in GitHub Desktop.
Reverse a string in javascript
var aString = "sometext";
reversed = [].slice.call(aString).reverse().join("");
//outputs "txetemos"
@Prinzhorn
Copy link
Copy Markdown

Shorter and without call magic.

aString.split('').reverse().join('')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment