design patterns - javascript polymorphism refactoring -


i have object maps properties functions, this:

var objfunctions = {   prop1: func1,   prop2: func2,   prop3: func3, }; 

now, need valid prop name call adequate function, example

   var callfuncprop = 'prop1'     objfunctions[callfuncprop]('value1'); 

this works fine, however, let's new function came up, , needs additional arguments. dynamically calling function additional arguments means other functions receive them

objfunctions[callfuncprop]('value1', 'value2', 'value3');  // calls func1 defined 1 parameter 

this works, have problem kind of design. how refactor code can still dynamically call functions pass additional arguments functions expects them ? avoid switch statement...


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -