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

# up.event.build([type], [props])

Builds an event with the given type and properties.

The returned event is not [emitted](https://unpoly.com/api/up.emit.md).

<nav aria-label="Contents">

#### Contents

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

</nav>

## Example {#example}

```js
let event = up.event.build('my:event', { foo: 'bar' })
console.log(event.type)              // logs "my:event"
console.log(event.foo)               // logs "bar"
console.log(event.defaultPrevented)  // logs "false"
up.emit(event)                       // emits the event
```

---

## Parameters {#parameters}

### [type] {#type}

(optional)

The event type.

May also be passed as a property `{ type }`.

Type: string

### [props={}] {#props}

(optional)

An object with event properties.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

### [props.type] {#props.type}

(optional)

The event type.

May also be passed as a first string argument.

Type: string

---

## Return value {#return-value}

The unemitted event object.

Type: [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event)

