In es-next we should be able to subclass an array

function createArraySubclass(proto, ...values) {
  return proto <| [...values];
}


However when we call `instanceOfSubArray.filter(...)` this method returns a
new Array rather then a new SubArray.

It would seem frustrating to have to overwrite all array methods that
return arrays and make them return subarrays.

Can we have array methods returning new instance of [[Prototype]] to make
it easier to overwrite the build in?

However this should only apply to true array subclasses. In the above
example I would assume the [[Class]] of the object is Array. It should not
apply to [].slice.call(arrayLikeObject)

Do we have other situations where it would make sense to return an instance
of whatever prototype your operation on rather then a hardcoded new X ?
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to