Reversing a string in JavaScript

Method-1:

var myString = $(‘#your_id’).val();

var reverseString= myString .split(“”).reverse().join(“”);

Method-2:

function reverse(s) {

var o = [];
for (var i = 0, len = s.length; i <= len; i++)
o.push(s.charAt(len – i));
return o.join(”);
}

alert(reverse(‘rawnA niassoH’));