What would be the most efficient in JS?
different functions / one function (extra parameter) with cases, if i had say 10 cases.
Here the question was already asked once but imho the question “what is the most efficient” was not really answered.
Two functions, or one function with different params?
If I were you I wouldn’t worry much about efficiency in such a high level example. what I would worry about is what approach would fit more in an extensibility sense (ala, the expression problem).
Functions that deal with the cases inside make it easier to add new kinds of function but make it harder to add a new kind of case (you would need to edit each existing function to do so).
On the other hand, functions/methods that are separate for each case make it easier to add new cases but make it harder to add a new kinds of function (since you would need to go back to each kind of case and add the new method to it)