Insights into building a solid I.T. foundation in the mid-size business world.

Truncate x characters from a string

Here’s a clever little function that enables you to, as the title suggests (!), truncate a predetermined number of a characters from a string:

myStr = myStr.slice(0, -x)

(where x is the number of characters to remove)

Leave a Reply

Your email address will not be published. Required fields are marked *