Skip to content

Function: arraysEqual() ​

ts
function arraysEqual<T>(
   a, 
   b, 
   comparator?): boolean;

Compares two arrays for equality. 比较两个数组是否相等。

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterTypeDescription
areadonly T[]First array / 第一个数组
breadonly T[]Second array / 第二个数组
comparator?(x, y) => booleanOptional custom comparator / 可选自定义比较器

Returns ​

boolean

true if arrays are equal / 相等时返回 true

Example ​

ts
arraysEqual([1, 2, 3], [1, 2, 3]) // => true
arraysEqual([1, 2], [2, 1]) // => false

Since ​

1.5.0

Released under the MIT License.