Comparing corresponding elements of two equal-length arrays I have a helper function I wrote, but it feels like something _.lodash already does or could do if I knew the library better.

function changed(before:any[], after:any[]):boolean[]
{
    if (before.length !== after.length)
    {
        throw new Error(`Length of arrays are not equivalent: ${before.length}, ${after.length}`);
    }
    else
    {
        let changed:boolean[] = [];
        for(let i = 0; i &lt; before.length; i++)
        {
            changed[i] = (after[i] !== before[i]);
        }
        return changed;
    }
}


An example of how this might be used and what would return:

console.log(changed([0,1,0,1], [0,1,1,0]))
// =&gt; [false, false, true, true]


Does anyone know if this can be elegantly achieved with lodash?
I don't know TypeScript or lodash, but I hope the following code is at least almost correct. You should be able to use zip and map to solve the problem in a functional manner.

function changed(a, b) {
    return _.zip(a, b).map(x =&gt; { return x[0] !== x[1] });
}


Basically, the problem of what has changed can be rephrased as which elements are equal.