In Javascript it is possible to do the same way, but it is necessary to break the string
for array
previously using the functions of split and then unite with Join. Because the string is immutable (immutable values (unable to change or mutate) are primitive values - numbers, strings, boolean, null, undefined). While the changeables are all other objects. They are usually referred to as reference types because the object values are references to the location, in memory, of which the value resides.)
var str = 'ABCD'.split('');
var i = 1;
var j = 2;
var aux = str[i];
str[i] = str[j];
str[j] = aux;
str = str.join('');
console.log(str);
Example: https://jsfiddle.net/xvwfnmd2/
That’s not exactly what I wanted. I edited the question to make it clear
– Phelipe