Skip to main content
Module

std/collections/omit.ts>omit

Deno standard library
Go to Latest
function omit
import { omit } from "https://deno.land/std@0.221.0/collections/omit.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.221.0/collections/omit.ts";
import { assertEquals } from "https://deno.land/std@0.221.0/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>