UNPKG

@gravityforms/utils

Version:
32 lines (31 loc) 763 B
/** * @module arrayEquals * @description Determines if two variables are both arrays and equal. * * @since 1.0.0 * * @param {Array} a First variable to be compared. * @param {Array} b Second variable to be compared. * * @category data * * @return {boolean} Returns true if both variables are arrays and are equal. Returns false otherwise. * * @example * import { arrayEquals } from "@gravityforms/utils"; * * function Example() { * const ary1 = ['a', 'b', 'c']; * const ary2 = ['a', 'b', 'c']; * const isEqual = arrayEquals( ary1, ary2 ); * } * */ export default function arrayEquals( a, b ) { return ( Array.isArray( a ) && Array.isArray( b ) && a.length === b.length && a.every( ( val, index ) => val === b[ index ] ) ); }