---
title: hypeDocument.runExpression
slug: hypedocumentrunexpression
description: Learn how to use the `hypeDocument.runExpression` function in JavaScript to evaluate expressions within the context of objects like hypeDocument. Access and modify important data, such as timeline and scene data, effortlessly. Make sure to declare variabl
docTags: 
createdAt: 2022-05-04T12:08:20.000Z
---

The `hypeDocument.runExpression` function allows you to run a JavaScript expression in the context of an object. The expression is evaluated in the context of the object, and the result is returned.

The most common use for this function is to run a JavaScript expression in the context of a hypeDocument. This allows you to access and modify the document's data, including its timeline and scene data.

For example, you could use `hypeDocument.runExpression` to do a calculation:

```javascript
hypeDocument.runExpression('c = Math.sqrt( a*a + b*b )');
```

The variable c would be looked up in  the hypeDocument's context and would be set to the result of the calculation.

Make sure to predeclare any variables you plan to use in your expression, otherwise they will not be accessible.

:::hint{type="danger"}
Hence, that this function mainly exists to provide the GUI version and mirror the functionality in code.
:::

