Add arrayEquals
function
#323
aleclarson
started this conversation in
Ideas
Replies: 1 comment
-
Alternative implementationA bit more flexible when working with optional arrays: export function arrayEquals(
a: unknown[] | null | undefined,
b: unknown[] | null | undefined,
): boolean {
if (!a) {
return !b
}
if (!b) {
return false
}
return (
a === b ||
(a.length === b.length && a.every((val, index) => Object.is(val, b[index])))
)
} Points of interest
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Caveats
Sparse arrays are not supported by the proposed implementation.
Beta Was this translation helpful? Give feedback.
All reactions