Рет қаралды 4,578
While the prototype object can sometimes seem like a distant concept that has no real application to the code you are writing, here is a practical example of how you can use it to your advantage.
You can take existing objects and add new functionality by adding properties or methods to their prototypes.
This example shows how to extend the Array object but you can apply this same technique to Arrays, Dates, or anything you want.
However, it is recommended that you don't extend any of the DOM objects as it could adversely affect performance.
Code GIST: gist.github.com/prof3ssorSt3v...