How to keep only first n characters in a string in JavaScript?

Is there any way I can remove extra characters from the end of the string in javascript? For example, I have a string containing 200-300 characters but I want to keep only the first 100 characters. How do I do that?

All you need is JavaScript’s String method substring

var yourString = ".......";
var result     = yourString.substring(0,100);

It will return the string starting at the first character and finishing before the 101st character.