I know that slice has time complexity of O(n) and so I wanted to know if its possible to remove the last character of string in JavaScript in Constant time?
For arrays we have pop method that I assume is Constant time however if I convert the string to array and then convert it back to string that would again mean O(N) which is linear time.
What's the difference between slice
and substr
method? Which is more performant? Why do we need substring
when we already have slice
?