Apparently it removes "array holes" which I did not know was a thing until right now. Apparently `[1, , 2]` is a thing (and is not the same as `[1, undefined, 2]`)
-
-
-
Replying to @mountain_ghosts @sgrif
the example I gave when this was being added to the lang is, what happens if you flatten [1, new Set([2, [3]]), 2, null, "hello"] I don't believe there's a well-defined answer to this question and I get tired just thinking about it
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts @sgrif
also I never actually want arbitrary flattening - if my data is arbitrarily deep, I want an interpreter or visitor - if my data is one level deep, I want flatMap - if I don't know how deep it is, I have a design problem
1 reply 0 retweets 1 like -
Replying to @mountain_ghosts
I'm with you that flatten should always be `flatMap(id)`. FWIW, `Array.prototype.flat` lets you pass a depth, but it defaults to 1 so other than the hole thing it is identical to `flatMap(id)`
1 reply 0 retweets 0 likes -
Replying to @sgrif @mountain_ghosts
Wow I really thought I was done being surprised by weird random shit in JSpic.twitter.com/Sja5Kj2S7k
2 replies 1 retweet 3 likes -
Replying to @sgrif @mountain_ghosts
Have you seen how an array’s length property is defined? https://www.ecma-international.org/ecma-262/5.1/#sec-15.4 … tl;dr it looks at properties on the object, determines which are array indexes, adds one to the largest, and bam, length.
1 reply 0 retweets 0 likes -
Replying to @brianarn @mountain_ghosts
> object has a length property whose value is always a nonnegative integer I'm pretty sure this is for a different language
1 reply 0 retweets 0 likes -
Replying to @sgrif @mountain_ghosts
I mean, it’s a Number but it can also be a non-negative integer
1 reply 0 retweets 0 likes -
Replying to @brianarn @mountain_ghosts
"The language spec has the concept of integers you just don't get to use them"
2 replies 0 retweets 0 likes
No but seriously that entire paragraph is just terrifying
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.