Question: 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?

Answer: 
Just use [brackets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors):

```
request[method](url, function(){...});

```
In your particular case `post` and `get` are properties of the request object, so you can access them with the help of [bracket notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Bracket_notation):

```
if(typeof request[method] === 'function') {
    request[method](url, function(){...});
}

```

You can also use [`eval()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/eval) function but it is not recommended, because it makes your code vulnerable for injection attacks, makes it harder to read and debug, and so on.