New Phone Models

    @writetome51/arrays-match

    2.0.3 • Public • Published

    npm version NpmLicense npm

    arraysMatch(array1, array2): boolean

    If array1 and array2 match, returns true.
    It automatically handles checking nested arrays.

    How the matching is done:
    If (array1 === array2), returns true.
    Else, it tries element-by-element matching:
    if array1[i] === array2[i] for every i in array1 and array2, it's a match.
    If array1[i] and array2[i] are both arrays of equal length, they're passed
    into a recursive function call.

    Examples

    arraysMatch([], []); // true
    
    arraysMatch(['h', 'j'],  ['h', 'j']); // true
    
    arraysMatch(['h', 'j'],  ['h', 'j', 'k']); // false
    
    arraysMatch([1, 2, [3]], [1, 2, [3]]); // true
    
    let obj = {prop: 1};
    arraysMatch([obj], [{prop:1}]); // false
    
    arraysMatch([obj], [obj]); // true
    
    let obj2 = obj;
    arraysMatch([obj], [obj2]); // true

    Installation

    npm i @writetome51/arrays-match

    Loading

    import {arraysMatch} from '@writetome51/arrays-match'; 

    Install

    npm i @writetome51/arrays-match

    DownloadsWeekly Downloads

    6

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    3.85 kB

    Total Files

    4

    Last publish

    Collaborators

    • writetome51