Using functional inheritance we can extend objects by passing them as the context of a function call assigning to this.
This doesn't seem to work as I'd expect for the Array constructor.
var ctx = {
foo: "foo"
};
Array.call(ctx);
ctx -> Object(foo: "foo")
Conversely this does work with other constructor looking functions.
var fakeArrayConstructor = function () {
this.length = 5;
}
fakeArrayConstructor.call(ctx);
ctx -> Object {foo: "foo", length: 5}
Does the Array constructor not assign some of its properties using this or is there something else going on? I know that a lot of the functionality associated with arrays is stored on Array.prototype however that's not my focus for this exercise.
Array.call(null, ctx)worksArray.call.