---
name: "up.util.evalOption"
area: "API"
kind: "JavaScript function"
parent: "up.util module"
url: "https://unpoly.com/api/up.util.evalOption"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.util module](https://unpoly.com/api/up.util.md)</nav>

# up.util.evalOption(value, ...args)

If the given `value` is a function, calls the function with the given `args`. Otherwise it just returns `value`.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

```js
up.util.evalOption(5) // => 5

let fn = () => 1 + 2
up.util.evalOption(fn) // result: 3
```

---

## Parameters {#parameters}

### value {#value}

(required)

Type: any

### ...args {#args}

(required)

Type: [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)

---

## Return value {#return-value}

Type: any

