---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Symbol.for()

The **`Symbol.for(key)`** method searches for existing symbols
in a runtime-wide symbol registry with the given key and returns it if found. Otherwise
a new symbol gets created in the global symbol registry with this key.

## Syntax

```js
Symbol.for(key)
```

### Parameters

- `key`
  - : String, required. The key for the symbol (and also used for the description of the
    symbol).

### Return value

An existing symbol with the given key if found; otherwise, a new symbol is created and
returned.

## Description

In contrast to `Symbol()`, the `Symbol.for()` function creates a
symbol available in a [global symbol registry](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol#shared_symbols_in_the_global_symbol_registry) list. `Symbol.for()` does also
not necessarily create a new symbol on every call, but checks first if a symbol with the
given `key` is already present in the registry. In that case, that symbol is
returned. If no symbol with the given key is found, `Symbol.for()` will
create a new global symbol.
