var x = “This is a long string”;

var slicedText = x.slice(10);

What do you think will happen in the above snippet of code? Your first guess would probably be that it will just trim the tenth character only, so ’slicedText’ will be set to ‘l’. While this is a very good and logical guess, in actuality, it simply starts trimming at the tenth character, but then finishes trimming at the very end of the string, regardless of its length. So the slicedText variable will actually be assigned to ‘long string’.

You can also use negative values here; you could very easily write this code: