Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Extending an existing component's capability

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 the capability to the existing component. For example, String is a standard object in JavaScript and we would like to add a new method, formatWithWordBreak, in such a way 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 the formatWithWordBreak method. This recipe will take us through the steps to achieve this requirement.

Getting ready

Make sure you have set up your development environment by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.