tc39 / proposal-flatMap

proposal for flatten and flatMap on arrays
https://tc39.github.io/proposal-flatMap
214 stars 19 forks source link

"was provided" should change to "!== undefined" #17

Closed ljharb closed 7 years ago

ljharb commented 7 years ago

The current proposal for flatten says "If depth was provided, then" - this means that .flatten() and .flatten(undefined) have different behavior.

Specifically, .flatten(undefined) would call FlattenIntoArray with NaN instead of Infinity, and thus NaN > 0 would immediately be false; whereas Infinity > 0 is true.

Generally the spec tries to avoid differentiating "absent" and undefined - I think this should change to "If depth is not undefined".

ljharb commented 7 years ago

Note that #14's change makes it so that () and (undefined) have observably the same behavior, since NaN is an effective depth of 1 - but this still seems worth cleaning up in the spec.