---
title: "omit"
description: "Return a new object that excludes the given keys, leaving the source untouched, useful for stripping fields before output."
canonical_url: "https://core.mhaibaraai.cn/en/docs/helpers/object/omit"
---
# omit

> Return a new object that excludes the given keys, leaving the source untouched, useful for stripping fields before output.

## Usage

The `omit` function returns a new object with the specified keys excluded.

```ts
import { omit } from '@movk/core'

const user = {
  id: 1,
  name: 'John',
  password: 'secret',
  email: 'john@example.com'
}

const publicUser = omit(user, ['password'])
console.log(publicUser) // { id: 1, name: 'John', email: 'john@example.com' }

const basicInfo = omit(user, ['password', 'email'])
console.log(basicInfo) // { id: 1, name: 'John' }
```

## API

### `omit<T, K>(obj, keys)`

Returns a new object with the specified keys excluded.

### Parameters

**obj** (`T extends AnyObject`) *required*: The source object.

**keys** (`K[]`) *required*: Array of keys to exclude.

### Returns

**returns** (`OmitByKey<T, K>`): A new object with the specified keys removed.

## Changelog

See commit history for [src/helpers/object/omit.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/helpers/object/omit.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/helpers/object/omit.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
