I am wondering about runtimes for replacing a character in a string (in javascript).
For example
let str = "hello world";
str[0] = "n";
console.log(str); // hello worldunder strict mode, this throws an error because you cannot modify strings (read only).
How would you implement an O(1) time, O(1) space algorithm in js to do str[index] = char? In C, this is trivial because access is O(1) and you can modify that element without having to allocate a new array and copy values over. 
I have found solutions using split to do this ... but isnt this overkill? That means O(n) time and space.
Wondering about this mostly for interview questions since I use javascript
 
     
     
    