Skip to content

isSymbol

The isSymbol function checks if the provided value is of type symbol.

Syntax

typescript
isSymbol(value: any): value is symbol;

Parameters

ParameterTypeDescription
valueanyValue to be checked

Returns

TypeDescription
booleanTrue if it is a symbol

Examples

typescript
isSymbol(Symbol("id")); // => true
isSymbol("id"); // => false

Notes

  • Useful for validating unique identifiers.

References

Released under the MIT License.