|
|
|
|
|
by kaoD
628 days ago
|
|
> Not talking about typescript. TS is just encoding JS semantics into a type system. A function returning a fixed-size array in JS is effectively returning, semantically, a tuple. They're just not a different type unlike in other languages (for different reasons). JS arrays are not even arrays since they (1) are not contiguous and (2) do not require items to be of the same size (typed arrays are actual arrays though) except by their backing implementation (which uses js vals, but that's a property of the implementation, not the language). They're sparse vectors. But nobody cares about that technical distinction and we still call fixed-size arrays tuples and variable-size arrays arrays. You can even attach properties to them because arrays are not vectors, they are objects. Or can be, for that matter. The backing implementations are complex and very dynamic. JS was intentionally made this simple so it could have emergent semantics. Scheme-ish. > Typescript wasn’t nearly as wide spread or as complete back then anyway. Facebook was still on flow. It was when they introduced hooks. |
|
Typescript is irrelevant.
The implementation of arrays in js is irrelevant.
Js being intentionally simple is irrelevant (and might even strengthen my point)