You can define your prototype like this:
Array.prototype.change = function (b) {
this.length = 0;
this.push.apply(this, b);
}
Internally it will clear existing data and add data from array in parameter.
This will not make Array a exactly equal Array b (they will still be different objects with different references and a == b
would be false
) but data in both will be the same.