Array.prototype.any to eventually replace Array.prototype.some

TLDR; Due to incorrect word semantics, I propose that Array.prototype.any be introduced as equivalent to Array.prototype.some, with the latter eventually being obsoleted.

The precise functionality of the operation in question is to return true if the array (or iterable in the future) contains 1 or more members. The term "some" is a poor choice because it does not match these semantics. When dealing with discrete quantities, "some" implies 2 or more. e.g. If I were to say "dear, please bring me some AA batteries," and she handed me a single battery, I would wonder about her.

In most languages with such a function, the terms "any" or "exists" are used. I would recommend "any" for ES since it is shorter, and is common in many current popular languages, such as C#, and Dart.

I propose that Array.prototype.any be introduced with equivalent functionality to Array.prototype.some, with the documentation stating that once supported on targeted platforms, "any" be the preferred choice. Eventually "some" could be phased out through obsolescence.

I don't agree that "some" implies 2+. More broadly, adding a synonym just to have a very slightly better name isn't generally worth the cost.

(The method also exists on Array, fwiw.)

Do you mean Array.prototype.some? There's no String.prototype.some.

Either way, introducing an alias is unlikely.

Yes, meant Array, thanks. Brain fart.

@tabatkins I don't think it's slight. When I first looked for the function, I looked for "isEmpty", "exists", and "any". It took a search to find "some", and even then I had to investigate the function to ensure the semantics were correct due to the obscure name. Years later it still annoys me and I wonder how many people are tripped up by it.

I don't feel like I get tripped up by the "some" name either, at least not until you brought this to my attention.

However, I do feel like "any" is a more natural choice. I also prefer "every" over "all". Each time I want to use one of these methods, I always think of the word "every" or "any", and then remember that that's not it, and have to remember what the real word is.

I've just assumed they ran with "some" and "all" because there were probably developers who had already extended the Array prototype to include "every" and "any", so adding native "every" and "any" methods would have been a breaking change on some webpages - I've seen lots of name changes happen for this reason.

I don't know if that's really the reason for their choice though :man_shrugging: