In some of my more recent posts about How to compare arrays in Javascript and Format Numbers as Currency with Javascript I have been enjoying adding them as extension methods to simplify their usage.
Honestly, I’ve always been afraid to do it because it seems “hard”. Now that I’ve done it once though, it is now becoming second nature. I really can’t believe I haven’t done this before because I absolutely love adding string extensions when I developer with C#.
Let’s take a look at some code to add a function with prototype using Javascript. In this first example I will add it to the Javascript Array Prototype: