A Note on Conditional Operators

There are a few things that I have learned today and I would like to mention them here so I can come back to them in the future.

The Difference Between == And ===

First of all, the difference between these two in JavaScript is that the first one compares whether the value of two things are the same but the second one also compares the datatype. So it’s like the second one is Value & Data Type (in a logical way).

Comparison operators return a boolean value.

Strings are Immutable!

Meaning that when you use a string method, the method doesn’t change the string but rather it actually creates a new string.

The boolean NOT operator is represented with an exclamation sign !

Another Way to write conditions

let accessAllowed = (age > 18) ? true : false;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *