Q:

I keep getting gt; when using substring or slice

I'm building a video player with playlist and using symbol ">" to indicate which video is currently playing. I have the following function:
player.onended = function () {
        pl.childNodes[curVideo + 1].childNodes[0].innerHTML = pl.childNodes[curVideo + 1].childNodes[0].innerHTML.slice(1);
        ++curVideo;
        if (playlist.length == 0) {
            player.setAttribute("src", "");
        }
        else if (curVideo < playlist.length) {
            player.setAttribute("src", playlist[curVideo]);
            pl.childNodes[curVideo + 1].childNodes[0].innerHTML = ">" + pl.childNodes[curVideo + 1].childNodes[0].innerHTML;
        } else {
            curVideo = 0;
            player.setAttribute("src", playlist[curVideo]);
            pl.childNodes[curVideo + 1].childNodes[0].innerHTML = ">" + pl.childNodes[curVideo + 1].childNodes[0].innerHTML;
        }
    }

I'm not changing this string anywhere else in the code, but when I delete this ">" with slice or substring instead of getting string without it I get this symbol replaced by "gt;".
Before deletion:
>htt://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4

After deletion:
gt;htt://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4

A:

You're assuming that > will come back to you as >. It isn't in your example, it's coming back to you as the named character reference &gt; instead. Remember, innerHTML is HTML. It's not strictly necessary to use a named character entity for > in most cases, but it's not uncommon.
This may or may not be reliable cross-browser, so to remove it, I'd probably do this if you need to work with innerHTML:
l.childNodes[curVideo + 1].childNodes[0].innerHTML =
    pl.childNodes[curVideo + 1].childNodes[0].innerHTML.replace(/^(?:>|\&gt;)/, "");
// ----------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...which will remove it at the beginning of the string whether it comes back as > or &gt;.
Alternately, use innerText or textContent, so you're not dealing with HTML.

