UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

14 lines (13 loc) 381 B
/** * Returns a new array with duplicate elements removed. * @param {T[]} array - The array to remove duplicates from. * @returns {T[]} A new array containing only unique elements. * @template T * @example * const arr = [1, 2, 2, 3, 4, 4, 5]; * const uniqueArr = unique(arr); // [1, 2, 3, 4, 5] */ export function unique(array) { return Array.from(new Set(array)); } ;