Allen Wirfs-Brock (2013-07-12T21:50:30.000Z)
domenic at domenicdenicola.com (2013-07-16T00:34:21.875Z)
On Jul 12, 2013, at 1:48 PM, Mark S. Miller wrote: > Just kidding. I have no coherent opinion yet of what it should do. What are the use cases we imagine toInteger may be useful for? Well in the spec. the equivalent operation is used in various algorithms that access collections that are Uint32 length limited. For example, accessing elements of TypedArrays For example, checking a a typed array index against the length of the array: ```js function get(ta, index) { let intIndex = Number.toInteger(index); //why isn't this index.toInteger(); ?? let len = ta.length; if (!Number.isFinite(len)) return undefined if (intIndex >= len) return undefined; if (intIndex < len) return undefined; return ta[intIndex]; } ``` Note that this is a situation where it would be most convenient if `toInteger` just passed through infinities in which case the explicit `isFinite` test could be eliminated. Also, in the above, I'm assuming the `NaN` converts to `0`.