1

Python, Ruby, Rust, Haskell, Kotlin, C#, C++, Perl, MATLAB, SQL, and R all call their respective array predicate checking functions any and all.

Is there any record of why JavaScript's designers decided to deviate from the naming convention other languages have used for these functions since the 90's?

Some Lisp-family languages (specifically Common Lisp and Clojure) seem to be the only other notable users of some and every.

4
  • 1
    Even C++ does it, sort of (they append _of). Aug 1 at 17:45
  • "JavaScript's designers"
    – Ewan
    Aug 1 at 17:50
  • Common Lisp uses some and every as well. How hard did you look? Aug 1 at 18:07
  • @PhilipKendall good catch, thanks! I've edited the question to refer to Lisp variants more generally. If you know of any others I'd be very interested to hear.
    – Alex Ryan
    Aug 2 at 19:43

2 Answers 2

1

The higher-order array methods map, filter, some, every were added to JavaScript by Mozilla in 2005. This was before Go, Rust, and Kotlin even existed (AFAIK) and before C# and Python had any/all. They became part of the ECMAScript standard with ECMAScript 5 in 2009.

The methods were almost certainly inspired by Lisp, which had similar functions for list processing. Lisp and Scheme were a strong influence on JavaScript. Scheme, a Lisp dialect, is specifically mentioned as an inspiration in the ECMAScript 5 specification (along with Java and Self).

Worth noting SQL supports both ANY and SOME as alias.

0

I cant find the notes for any and all but you can see this proposal for includes

https://github.com/tc39/proposal-Array.prototype.includes

which mentions:

Why includes instead of has? If you survey existing APIs, has is used for conceptual "keys," whereas includes is used for conceptual "values."

And the notes on the discussion:

Array.prototype.includes

DD: CC + FF in betas

DD: Test262 works

DD: Safari doesn't have TypeArray.prototype.includes

DD: Stage 4?

DD: should it be in unscopables?

BT: if it not in unscopeables it may be ok?

BT: real world with no breaks, should be good.

DD: lets make it unscopable

DD: stage 4?

YK: yup

Conclusion/Resolution Move to stage 4 (tomorrow when it's added to @@unscopables)

Presumably the same kind of thought went into any and all what does the underlying engine support? what do we have already? etc

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.