Listing the differences between corresponding elements of two arrays or two objects
The simplest answer is to remove deltaArray and use deltaHash for everything. As long as your arrays don't have any extra properties, the results will be identical, except the keys are stored as strings instead of numbers.



I'm not sure it's useful to store the keys in one array and the values in another. Storing the keys in an array could be useful if ordering the keys is important, but that doesn't apply here (since we got the keys from a for...in loop, we encountered them in an undefined order). So, you could let the keys be keys and let the values be values, and if you need an array of keys, use Object.keys.

var deltaHash = function(a, b) {
    var delta = {};
    for (var key in b)
        if (a[key] !== b[key])
            delta[key] = b[key];
    return delta;
};


If you still want a separate function for arrays, it would look like this:

var deltaArray = function(a, b) {
    var delta = {};
    for (var i = 0, l = a.length; i &lt; l; ++i)
        if (a[i] !== b[i])
            delta[i] = b[i];
    return delta;
};


You'd still probably want to eliminate redundancy in this case. We could extract the duplicated code into a separate function and end up with something like this:

var diff = function(a, b, delta, key){
    if (a[key] !== b[key])
        delta[key] = b[key];
};

var deltaHash = function(a, b) {
    var delta = {};
    for (var key in b)
        diff(a, b, delta, key);
    return delta;
};

var deltaArray = function(a, b) {
    var delta = {};
    for (var i = 0, l = a.length; i &lt; l; ++i)
        diff(a, b, delta, i);
    return delta;
};


Somehow that's not very satisfying, though; it still feels redundant. What we have at this point really feels like it wants to be more of a classical design: 

function Delta() { }

Delta.prototype.diff = function(a, b, key) {
    if (a[key] !== b[key])
        this[key] = b[key];
};

Delta.prototype.initFromArrays = function(a, b) {
    for (var i = 0, l = a.length; i &lt; l; ++i)
        this.diff(a, b, i);
};

Delta.prototype.initFromObjects = function(a, b) {
    for (var key in b)
        this.diff(a, b, key);
};


But again, most of this is not necessary if you decide to build deltas for arrays the same way you build them for other objects, using something like your original deltaHash for both. Aside from some possible naming and stylistic issues, and the awkwardness of having the keys in a separate array, it should do the trick (although you might want to add a hasOwnProperty check, and use push).

Hope this gives you some ideas.