I have function with parameters method and url, where method can be equal to get, post, etc. I can do like this
var req = function(method, url) {
if(method == 'get') {
request.get(url, function(){...});
}
else if(method == 'post') {
request.post(url, function(){...});
}
}
or use switch. But I wonder is there any way to do it without using any condition, but calculate variable value during calling of the function?
request[method](url, function(){...});... as long as '...' is identical