---
title: "isDeepEqual"
description: "Structurally compare plain data (primitives, arrays, own enumerable keys) so fresh literals with identical values count as equal."
canonical_url: "https://core.mhaibaraai.cn/en/docs/helpers/object/is-deep-equal"
---
# isDeepEqual

> Structurally compare plain data (primitives, arrays, own enumerable keys) so fresh literals with identical values count as equal.

## Usage

`isDeepEqual` recursively compares primitives, arrays and own enumerable keys, which suits deciding whether plain data such as options has really changed.

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

isDeepEqual({ a: [1, 2] }, { a: [1, 2] }) // true
isDeepEqual({ a: { b: 1 } }, { a: { b: 2 } }) // false
isDeepEqual({ a: 1 }, { a: 1, b: undefined }) // false
isDeepEqual(Number.NaN, Number.NaN) // true
```

> [!NOTE]
> 
> Compared with 
> 
> equalsBy
> 
> : 
> 
> equalsBy
> 
>  decides whether two values refer to the same item (by id and similar keys), while 
> 
> isDeepEqual
> 
>  decides whether two pieces of data have identical content.

> [!WARNING]
> 
> Internal state of built-ins such as 
> 
> Map
> 
> , 
> 
> Set
> 
> , 
> 
> Date
> 
>  or class instances is not compared, and circular references are not supported. Use it for plain data only.

## API

### `isDeepEqual(a, b)`

Structural deep comparison for plain data.

### Parameters

**a** (`unknown`) *required*: Value to compare.

**b** (`unknown`) *required*: Value to compare.

### Returns

**Returns** (`boolean`): true when structure and values are identical.

## Changelog

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

---

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


## Sitemap

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