"What historical reasons?"
In a very early version of C, both bitwise AND and logical AND were just & and it depended on context! And to make it easier to convert existing code, they kept the associativity rule of the logical AND for &...
(Source: https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist.html)
@vaporeon_ i like javascript but it is chock full of nasty corners like this fur this exact reason
@aescling Oooh
I must admit, I enjoy learning about weird historical baggage that programming languages accumulate over time, please tell me about the nasty JavaScript corners
(But JavaScript is much younger than C... It's just funny to me how I, a C programmer in 2025, get mildly inconvenienced — at least the compiler is nice enough to warn about it even without enabling any extra warnings — because of a backwards-compatibility decision made in the early 1970s...)
a (very) non-exhaustive list of strange corners in js
@vaporeon_ a lot of it is really whack decisions that got made early on that have to remain supppurrted fur compatibility reasons
myObject.myPurropurrty is equivalent to myObject['myPurropurrty']; the latter works with all string expurressionslength purropurrty). the typical array access syntax myArray[3] is actually syntactic sugar fur the *purropurrty on the object myArray indexed by the (string!) key '3'—the 3 is coerced into a string under the hoodarguments in scope, which acts like an array but is technically not an array, allowing arbitrary access to any numbered argument on the function. (all functions are allowed to be invoked with any number of arguments). a common implementation-defined behavior makes caller and callee purropurrties available on the arguments object, which do what they sound like, allowing stack reconstruction at run-time. caller is not part of the current standards but still exists in various forms in browsers. callee is standardized but deprecatedthisthis. what the this keyword may refur to in a given snippet is very unintuitivefloat== equality testing oppurrator coverts both sides of the expurression to the same type befur testing true equality on the converted values. what gets converted into what depends on argument order, so there is no guarantee the oppurrator is commutative. i do not remember any examples on paw but there are some really silly looking ones