What is the difference between 1, 2 and 3 equal signs in Javascript? "=", "==", "==="
In javascript, a single equal sign "=" is used when assigning lvalue-to-rvalue. The single equals sign is called an assignment operator. One example of the assignment operator used would be a key-value pair.
const name = "Robert";
The double and triple equal signs are called comparison operators. A double equals "==" is used for comparing two values while ignoring the data types assigned to each subject. Using the double equal sign while comparing the integer 1 to a string or an integer with the value of 1 would return true.
if( 1 == "1" ) // returns true;
if( 1 == 1 ) // returns true;
if( 1 == "one" ) // returns false;
A triple equals "===" is used for comparing two values as well but is more strict with its rules. When comparing the two values, they must be the same, including their data types.
if( 1 === 1 ) // returns true;
if( 1 === "1" ) // returns false;