Is there a more streamlined approach to implementing this particular design pattern?
function a() {
function x() { /* code */ }
function y() { /* code */ }
/* additional code */
x(); y(); // can be called from here
}
a();
a.x();
a.y();
I recently learned about prototypes, so I thought of using something like this:
a = function() { }
a.prototype.x = function() { }
a.prototype.y = function() { }
But is there a simpler method? Considering that in my code a
also belongs to the prototype of something else, such as
function plugin() { ... }
plugin.prototype.a = function () {}
plugin.prototype.a.prototype.x = function () {}
plugin.prototype.a.prototype.y = function () {}