@technobuddha > library > Object > Mutation
Function: clear()
ts
function clear<T>(input: Record<string | number | symbol, T>): Record<string | number | symbol, T>;Defined in: clear.ts:15
Delete all own enumerable string properties from an object
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T | unknown | Type of values within the object |
Parameters
| Parameter | Type | Description |
|---|---|---|
input | Record<string | number | symbol, T> | Object to clear all properties |
Returns
Record<string | number | symbol, T>
Original input with all properties deleted.
Remarks
The input argument is mutated in place
Example
typescript
const obj = \{ a: 1, b: 2 \};
clear(obj); // obj is now \{\}