Короче сидел мудрил и вот че намудрил (работает только в Firefox)
var MyArray = function(){
var internal = Object.create(null, {length: {value: 0, enumerable: false, writable: true}});
var proto = MyArray.prototype;
return Proxy.create({
get: function(receiver, name) {
if (name in internal) {
return typeof internal[name] == 'function' ? internal[name].bind(internal) : internal[name];
}
if (name in proto) {
return typeof proto[name] == 'function' ? proto[name].bind(internal) : proto[name];
}
return undefined;
},
set: function(receiver, name, value) {
if (name === 'length') {
throw 'Not implemented';
}
if (!isNaN(name) && (name == +name)) {
name = +name;
if (internal.length <= name) {
internal.length = name + 1;
}
}
internal[name] = value;
}
});
};
MyArray.prototype.push = function() {
for (var i = 0; i < arguments.length; i++) {
this[this.length++] = arguments[i];
}
};
MyArray.prototype.join = function(separator) {
var values = [];
for (var i = 0; i < this.length; i++) {
values.push(this[i]);
}
return values.join(separator);
}
var a = new MyArray();
a.push('x','y')
console.log(a.join())
console.log(a.length)