I have been experimenting using static methods in Javascript. Instead of having objects inherit from a prototype, I use duck-typing a lot harder.
var Controller = {};
Controller.getData = function() {//return data};
// and then in use:
var page = route.getPage();
require([page], function(Controller) {
Controller.getData();
});
I could do this same by creating new objects with the Controller prototype:
function Controller() {};
Controller.prototype.getData = function() {//return data};
// and then in use:
var page = route.getPage();
require([page], function(Controller) {
var controller = new Controller();
controller.getData();
});
My gut feeling is that the static method will be faster, but I have no clue. In general, what are the performance discrepancies between these two methods?
TLDR; basically this question but for Javascript.