---
name: "up.util.copy.key"
area: "API"
kind: "JavaScript property"
parent: "up.util module"
url: "https://unpoly.com/api/up.util.copy.key"
---
<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.copy.key

This property contains the name of a method that user-defined classes may implement to hook into the [`up.util.copy()`](https://unpoly.com/api/up.util.copy.md) protocol.

## Example {#example}

We have a user-defined `Account` class that we want to use with [`up.util.copy()`](https://unpoly.com/api/up.util.copy.md):

```js
class Account {
  constructor(email) {
    this.email = email
  }

  [up.util.copy.key]() {
    return new Account(this.email)
  }
}
```

> #### Note
>
> The protocol method is not actually named `'up.util.copy.key'`. Instead it is named after the _value_ of the `up.util.copy.key` property. To do so, the code sample above is using a [computed property name](https://medium.com/front-end-weekly/javascript-object-creation-356e504173a8) in square brackets.

We may now use `Account` instances with [`up.util.copy()`](https://unpoly.com/api/up.util.copy.md):

```js
original = new Account('foo@foo.com')

copy = up.util.copy(original)
console.log(copy.email) // prints 'foo@foo.com'

original.email = 'bar@bar.com' // change the original
console.log(copy.email) // still prints 'foo@foo.com'
```

---

## Value {#value}

### key {#key}

Type: string

