JavaScript got a prototype inheritance system, in which we make available all properties to be extended by annexing them all to a constructor function’s property object {} called prototype:
For example If we wanna extend the class p5 (classes are constructor functions btW) w/ a new method called square(), we can simply annex it to p5.prototype{} object, like this:
p5.prototype.square = function (x, y, size) {
return this.rect(x, y, size, size);
};
And a more complex example, but now extending the class p5.Image instead, w/ a new method called resizeNN():