The first value to compare.
The reference array.
true if the arrays are the same, false otherwise.
const refArr = [1, 2, 3];
const unknownArr: unknown = [1, 2, 3];
isSameArr([1, 2, 3], [1, 2, 3]) => true
isSameArr([1, 2, 3], [1, 2, 3, 4]) => false
isSameArr([1, 2, 3, 4], [1, 2, 3]) => false
isSameArr([1, 2, 3], []) => true
isSameArr([], [1, 2, 3]) => false
isSameArr({}, [1, 2, 3]) => false
isSameArr([1, 2, 3], [3, 2, 1]) => false
Checks if two arrays are the same. Two arrays are considered the same if they have the same length and their elements are strictly equal at each index. This function acts as a type guard, narrowing the type of
bto be the same asaif it returnstrue.