Your code does not mutate the string.
Strings (along with the other primitive types) are immutable in JS.
Mutating something means that changing it without creating another one.
String modifier methods return a new string, but doesn't change the original, for example:
const a = 'Hello world!'
const b = a.slice(0,5)
console.log(a) //Hello world!
console.log(b) //Hello
However, you can still reassign a string variable with a new string (but that's not mutation):
let a = 'Hello world!'
a = a.slice(0,5)
console.log(a) //Hello
Your code is a bit more complicated. String#split()
returns an array of strings, but doesn't mutate the original:
const a = 'Hello world!'
const b = a.split('o')
console.log(a) //Hello world!
console.log(b) //['Hell', ' w', 'rld!']
Arrays are (in fact) objects, and they are mutable, but not the strings (and other primitives) they contain.