About 78,600 results
Open links in new tab
  1. javascript - How do you reverse a string in-place? - Stack Overflow

    To answer your initial question — how to [properly] reverse a string in JavaScript —, I’ve written a small JavaScript library that is capable of Unicode-aware string reversal. It doesn’t have any of the issues I just mentioned.

  2. Reverse String in JavaScript - Stack Overflow

    Sep 29, 2014 · const result = document.querySelector('#result'); const RString = stringFactory(); // constructor const myReversed = new ReverseString('hello world'); myReversed ...

  3. Reversing a string in JavaScript - Stack Overflow

    Nov 9, 2024 · // You could reverse a string without creating an array String.prototype.reverse= function(){ var s= '', L= this.length; while(L){ s+= this[--L]; } return s; } var s1= 'the time has come, the walrus said, to speak of many things'; s1.reverse() /*returned value: (String) sgniht ynam fo kaeps ot, dias surlaw eht, emoc sah emit eht */

  4. javascript - Reversing a string - Stack Overflow

    Mar 29, 2011 · the other answers are entirely correct if your string has only 1 space between words. if you have multiple spaces between words, then things are a bit different: to get just the words, in reverse order, rejoined by 1 space:

  5. javascript - Reverse a String in JS - Stack Overflow

    In order to convert the array back into a string, you can use the method join( ) again, with an empty string as the argument. Using these concepts, you'll find a common solution to reversing a string. function reverseString(str) { return str.split( '' ).reverse( ).join( '' ); }

  6. How to reverse a string in JavaScript using a "for...in" loop?

    Jan 4, 2018 · Reverse String in JavaScript. 1. Reversing a string in JS. 2. Reverse String In Place Using for loop in ...

  7. Reverse a string in JavaScript without using an array

    Oct 28, 2022 · If we try to access string using an index it works fine. For example console.log(test[2]) returns 'l' But reversing a string using the method above returns unchanged string 'hello'. We need to use an array, reverse it and then join it to return the reversed string. But in that case we will be using an extra space.

  8. Reverse a string in javascript without using any inbuilt function

    Aug 15, 2017 · Reverse String in JavaScript. 1. Reversing a string in JS. 5. How to reverse characters in words of a ...

  9. Como inverter uma string em JavaScript?

    Uma alternativa é usar o spread na string, ao invés do split, para transformar em um array e aplicar o método reverse() e join() para alcançar o mesmo objetivo. De exemplo, vou reaproveitar o código acima, fazendo apenas o ajuste para usarmos o spread.

  10. javascript - Substring with reverse index - Stack Overflow

    Jan 13, 2016 · Reverse a string in javascript. 5. Reverse String in JavaScript. 1. issue with substring indexing. 1. How ...

Refresh