arrayEqual.js 330 B

12345678910111213141516
  1. 'use strict';
  2. /**
  3. * Tests if two arrays are equal.
  4. *
  5. * @param {unknown} a
  6. * @param {unknown} b
  7. * @returns {boolean}
  8. */
  9. module.exports = function arrayEqual(a, b) {
  10. if (!Array.isArray(a) || !Array.isArray(b)) return false;
  11. if (a.length !== b.length) return false;
  12. return a.every((elem, index) => elem === b[index]);
  13. };