without
function without<T>(array: T[], ...values: T[]): T[];
Values are compared with SameValueZero: without([NaN], NaN) returns [], which an indexOf scan cannot do because strict equality never matches NaN. -0 and 0 match each other.
The exclusions are collected into a set once, so the cost stays linear in the length of the array instead of the quadratic scan filter plus includes would perform. A new array is returned; the input is not modified. Called with no exclusions, without returns a copy.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The array to filter. Left untouched. |
|
| The values to exclude. |
Returns
T[] — a new array without those values, in their original order.
Throws
Exception | Condition |
|---|---|
|
|
Examples
Excluding values
without([1, 2, 3, 2], 2); // => [1, 3] — every occurrence
without([1, 2, 3], 2, 3); // => [1]
without([1, 2], 9); // => [1, 2] — nothing to remove
without([NaN, 1], NaN); // => [1]
Dropping the blanks a column comes with
import { without } from "apps-script-utils";
const names = sheet.getRange("A2:A").getValues().flat();
without(names, "", "N/A"); // the real entries, in sheet order
Removing a column from a header row
/**
* Hides the internal columns from a header row before it is shown to a user.
*/
export function visibleHeader(header: string[]): string[] {
return without(header, "internalNote", "_rowHash");
}
function visibleHeader(header) {
return without(header, "internalNote", "_rowHash");
}
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.