Skip to main content

Empty an array

JavaScript version

const empty = (arr) => (arr.length = 0);

// Or
arr = [];

TypeScript version

const empty = <T,_>(arr: T[]) => (arr.length = 0);

// Or
arr = [];

Comments