UNPKG

@wordpress/is-shallow-equal

Version:
26 lines (22 loc) 504 B
/** * Returns true if the two arrays are shallow equal, or false otherwise. * * @param {any[]} a First array to compare. * @param {any[]} b Second array to compare. * * @return {boolean} Whether the two arrays are shallow equal. */ export default function isShallowEqualArrays( a, b ) { if ( a === b ) { return true; } if ( a.length !== b.length ) { return false; } for ( let i = 0, len = a.length; i < len; i++ ) { if ( a[ i ] !== b[ i ] ) { return false; } } return true; }