|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
747 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Checks if two arrays are equal, treating empty arrays as equal regardless of reference.
|
|---|
| 3 | * If both arrays are non-empty, it checks for reference equality.
|
|---|
| 4 | * @param a
|
|---|
| 5 | * @param b
|
|---|
| 6 | */
|
|---|
| 7 | export function emptyArraysAreEqualCheck(a, b) {
|
|---|
| 8 | if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {
|
|---|
| 9 | // empty arrays are always equal, regardless of reference
|
|---|
| 10 | return true;
|
|---|
| 11 | }
|
|---|
| 12 | return a === b;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * Checks if two arrays have the same contents in the same order.
|
|---|
| 17 | * @param a
|
|---|
| 18 | * @param b
|
|---|
| 19 | */
|
|---|
| 20 | export function arrayContentsAreEqualCheck(a, b) {
|
|---|
| 21 | if (a.length === b.length) {
|
|---|
| 22 | for (var i = 0; i < a.length; i++) {
|
|---|
| 23 | if (a[i] !== b[i]) {
|
|---|
| 24 | return false;
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 | return true;
|
|---|
| 28 | }
|
|---|
| 29 | return false;
|
|---|
| 30 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.