-
Notifications
You must be signed in to change notification settings - Fork 19
How about .get()
instead of .at()
?
#37
Comments
Having the same name as Map.prototype.get imo would add confusion - arrays are list-like, not strict-like, so Set, not Map, would be a better analogue - but also, Maps have keys, not indexes. |
But I find my second item more important: What would a write operation be called if the read operation is called |
Sparse arrays are something that the newer parts of the spec tries very hard to pretend don’t exist :-) A write operation could still be called “set” - there’s no requirement that both get/set or neither be present - but i also don’t think anyone’s proposed a write operation. What would one have been called when this proposal was called “item”? |
|
I agree with your user expectation point for sure. I think the first thing that would have to be established is that there’s a problem that needs to be solved that would need negative indexing to assign directly to an index in an array. |
I don't love introducing some FUD but I believe .get and .set methods would be eventually revealed as web incompatible. Otherwise they would be nice.
|
I think it comes down to whether there will ever be a setter. One way to get numbers would be to look for the following pattern in code bases:
And then count how often the context is getting and how often setting. |
|
Note, another issue is , That means, if programmers refactor code |
Benefits:
Map.prototype.get()
..set()
later.The text was updated successfully, but these errors were encountered: