In the previous recipe, we defined a new component and used it in our application. However, in some cases, the choice may not be to define a new component. Rather, we may have to see if we can add a capability to the existing component. For example, String
is a standard object in JavaScript and we would like to add a new method—formatWithWordBreak
—so that once it is added, it is available to the complete application code to make use of this new method without defining a MyString
class and using it wherever we need formatWithWordBreak
. This recipe will take us through the steps to achieve this requirement.
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.