Skip to main content
Version: 2.x

API Reference > @easyops-cn/brick-next-pipes > equal

equal() function

比较两个值是否相同(深度比较)。

Logic

Signature:

export declare function equal(value: unknown, other: unknown): boolean;

Parameters

ParameterTypeDescription
valueunknown被比较的值。
otherunknown比较值。

Returns:

boolean

如果两者相同返回 true,否则返回 false

Remarks

透传调用 _.isEqual

**Note:** This method supports comparing arrays, array buffers, booleans, date objects, error objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. Object objects are compared by their own, not inherited, enumerable properties. Functions and DOM nodes are **not** supported.

Example

let object = { user: "fred" };
let other = { user: "fred" };

equal(object, other);
// => true

object === other;
// => false