Putting things into perspective- Examples

If you're having a hard time staying awake while reading
this tutorial, I can't say I blame you. The prototype object of JavaScript
isn't exactly as flashy and fun to learn as say, document.bgColor or
window.open, and the rewards aren't always instant. But if you're at all
interested in extending JavaScript and creating your own objects and
libraries, the prototype object is a must learn. Allow me to show you now a
couple of practical examples on using the prototype object of JavaScript:

-Example 1-Extending functionality to the pre-built
string() object

As mentioned earlier in this tutorial, the prototype object
can be used on pre-built JavaScript objects created with the
new keyword to add custom properties/ methods to them. Let's see an
interesting example on how to extend the prebuilt
String object of JavaScript to include a method that writes any
string backwards when called upon:

For the most part, you'll probably be using the prototype
object to extend and expand a custom JavaScript object you created earlier.
JavaScript developers who create custom objects often know that the
traditional way of assigning custom properties/ methods to an object isn't
exactly a walk in the park (See "Creating Custom
objects in JavaScript"). With the prototype object at hand, however,
this process becomes a lot simpler and intuitive.

I'll quickly demonstrate the concept by first creating a
"dummy object", and using the prototype object- and only this object- to
equip the dummy object with properties and methods: