Create an object that names functions the way you want:
var obj = {
"write": function(param) {
//Write param
},
"return": function(param) { //Enclosing the function name is quotes lets you use reserved words as function names
//Return param
}
};
You could write your function to simply look up the members in that object using array notation:
function do(param1, param2) {
obj[param1](param2);
}
Doing it this way would be much easier to maintain and would be much more scalable. However, I wouldn't even do it that way. I'd replace the do function with the object itself and then you could simply call these members the old fashioned way:
obj.write("Something");
Or, if the name return causes problems and you really want to use it:
obj["return"]("Something");
There's alot of power and flexibility in JavaScript objects and functions.