truncate Summary Cuts off the string at the specified length (number of characters). Signatures Click on a signature to select it and view its documentation. public string truncate(int length) public string truncate(int length, string ellipsis) Usage public string truncate(int length) public string truncate(int length, string ellipsis) Returns The string cut to the specified length with the removed text replaced with a single ... ellipsis. The string cut to the specified length with the removed text replaced with the specified ellipsis. Parameters length The number of characters to limit the string to before cutting off characters (zero-based). If this number is negative, it will be treated as zero. Parameters length The number of characters to limit the string to before cutting off characters (zero-based). If this number is negative, it will be treated as zero. ellipsis The text to replace the truncated characters with. Description The truncated characters are replaced with the ... ellipsis. The truncated characters are replaced with the specified ellipsis. Examples Basic Usage 123string text = "The quick brown fox jumped over the lazy dog."; Console.log(text.truncate(9)); // "The quick..." Basic Usage 123string text = "The quick brown fox jumped over the lazy dog."; Console.log(text.truncate(9, " [removed]")); // "The quick [removed]" Share HTML | BBCode | Direct Link