In order to reduce memory usage, I would like to assign several Javascript classes a prototype function.
My previous example was inadequate to explain the situation. A new, contrived example is shown below. In production scenarios, the function will likely have many more arguments, many more classes and instances will be using the prototype; some of which may be written by other developers.
function displayWeightedScore(metricOne, metricTwo, metricThree) {
console.log((metricOne * 0.15) + (metricTwo * 1.25) + (metricThree * 0.5));
}
ScoringSystemOne.prototype.displayWeighedScore = displayWeightedScore;
CalculatorTwo.prototype.displayWeightedScore = displayWeightedscore;
ScoreCalculatorThree.prototype.displayWeightedScore = displayWeightedScore;
//etc..
Each class needs to pass in a different set of metrics or some of the same metrics in a different order. To me this means I would then write a closure or object method to capture the class-specific arguments and ordering and then call the prototype function.
However, I understand this will negate the memory savings of using prototype functions in the first place.
Is there a neat trick, some form of syntactic sugar, or best-practice technique to binding a set/ordering of arguments (arguments either unique per-class or per-class-instance) to a prototype function call without losing the memory savings of using prototypes?