Skip to main content
Module

std/collections/mod.ts>omit

The Deno Standard Library
Go to Latest
function omit
import { omit } from "https://deno.land/std@0.222.1/collections/mod.ts";

Creates a new object by excluding the specified keys from the provided object.

Examples

Example 1

import { omit } from "https://deno.land/std@0.222.1/collections/omit.ts";
import { assertEquals } from "https://deno.land/std@0.222.1/assert/assert_equals.ts";

const obj = { a: 5, b: 6, c: 7, d: 8 };
const omitted = omit(obj, ["a", "c"]);

assertEquals(omitted, { b: 6, d: 8 });

Type Parameters

T extends object
K extends keyof T

Parameters

obj: Readonly<T>
keys: readonly K[]

Returns

Omit<T, K>