Skip to content

@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 ParameterDefault typeDescription
TunknownType of values within the object

Parameters ​

ParameterTypeDescription
inputRecord<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 \{\}