Skip to content

isWeakMap

The isWeakMap function checks if the provided value is an instance of WeakMap.

Syntax

typescript
isWeakMap(value: any): value is WeakMap<any, any>;

Parameters

ParameterTypeDescription
valueanyValue to be checked

Returns

TypeDescription
booleanTrue if it is an instance of WeakMap

Examples

typescript
isWeakMap(new WeakMap()); // => true
isWeakMap({}); // => false

Notes

  • Useful for validating collections before performing WeakMap-specific operations.

References

Released under the MIT License.