Allen Wirfs-Brock (2014-03-04T17:23:28.000Z)
domenic at domenicdenicola.com (2014-03-07T21:43:34.564Z)
There's actually a big difference between %TypedArray%.from and Array.from. The typed array version must accurately determine the number of elements in the new array be instantiating it. The regular array can pre-instantiate the new array and dynamically adjust its length. This affects a number of details of the algorithms. There are other cases where there are variations to the array method algorithms necessary to deal with the potential spareness of regular arrays. This is the case for several of the array methods but for many of them, the same algorithmic description can be used for both Arrays and Typed Arrays. In those cases, the ES6 spec. doesn't duplicate the algorithm but instead the Typed Array method specification simply reference the corresponding Array method specification. For example: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.foreach There was one issue I had to make a decision on. In the cases where the same algorithm was applicable to both Array and typed Array should a single (same identify) function be used in both Array.prototype and %TypedArray%.prototype or should a distinct function be used for each. I choose the latter because it seems to allow for more implementation flexibility. There are lots of ways that some of these algorithms might be optimized if you know you are dealing with a typed array. I wanted to give implementations that option and the most straightforward way to do so is to simply say that, for example, Array.prototype.foreach and %TypedArray%.prototype.forEach are distinct function objects. That way they can have distinct implementations. However, if an engine whats to share the same implementation level code between the two functions it could still do that.