Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

languages that always had triple equals

What popular programming languages were intentionally designed from the beginning to have both === and == (and require the programmer to figure out which one to use).
Javascript, PHP, ruby (and probably others) have a triple equals operator today. But, it is not clear if this was a deliberate design decision, or happened only by accident (perhaps because the language started with double equals, but at some point it was discovered that double equals wasn't quite doing what people wanted it to do).
Specifically in javascript, does anyone remember if it had the triple equals when it first came out?

like image 793
mattsh Avatar asked Oct 18 '11 06:10

mattsh


People also ask

What programming language uses 3 equal signs?

Using 3 equal signs forces Javascript to do stricter comparisons.

What programming language uses ==?

Comparing Values and Types In Python, we use the == operator to compare if two values and their data types are equal.

What is === in Python?

The === operator checks to see if two operands are equal by datatype and value.

What does === mean in Java?

On the other hand === is known as strictly equality operator. It's much similar Java's equality operator (==), which gives compilation error if you compare two variables, whose types are not compatible to each other. In fact, you should always use "===" operator for comparing variables or just for any comparison.


1 Answers

Since my memory isn't very reliable, I can't say that I remember either or, but since ECMA has kindly kept all revisions of the ECMA-262 specification, it's possible to defer from reading them when the "The Strict Equals Operator" was introduced into the language.

I can't find any mention of it in neither ECMA-262 1st Edition, nor ECMA-262 2nd Edition, but in ECMA-262 3rd Edition we find mention of it in chapter 11.9.4 (page 56). The natural conclusion to draw from this is thus: No, JavaScript did not have === when it first came out.

Since the other languages you mention aren't (as far as I know) ratified in any standardisation body, I guess it's harder to find old revisions of the language's specification, if there is any such thing as a specification for the language at all.

It's important to note, however, that the meaning of === in Ruby can be widely different than in JavaScript or PHP (where it is fairly similar). In Ruby, it's usually used for "subsumption", i.e. to check whether something exists within something else (a set, for instance), while in the two other langauges, it's used for strict equality checking, which means no type conversion is performed on either side of the operator before applying it.

like image 121
Asbjørn Ulsberg Avatar answered Oct 04 '22 08:10

Asbjørn Ulsberg