I need to find a smart way of truncating a string based on a specific scope or window. There is an absolute example too, that is Instagram's profile page. If you go there and reduce the screen size, you'll see username gets cropped from last characters each time respectively to the screen size.
How to do that in Javascript?