Of course you can extend both the String and Date classes in Javascript the same as you can with any other Javascript class. You can even extend the class for pre-existing objects that you created before extending it although doing that could become confusing.

Being able to add a trim() method to Strings or a getWeek() method to dates can often make the code much easier to read.