---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# DOMException.prototype.code

The **`code`** read-only property of the `DOMException` interface returns one of the legacy [error code constants](./DOMException.mdx#error-names), or `0` if none match.

This field is used for historical reasons. New DOM exceptions don't use this anymore: they put this info in the [`name`](./name.mdx) attribute.

## Value

One of the [error code constants](./DOMException.mdx#error-names), or `0` if none match.
