What Is The Difference Between The Operators == & ===?

Asked 3 months ago
Answer 1
Viewed 104
1

The value is assigned using "=". Example: If x = 2, then x has a value of 2. "==" is used to demonstrate value equality. Example x == y: in this case, y's value is equal to x. The notation = is used to assign values, such as x=3 y=3. The notation == is used to compare if two values are equal, such as if(x==y) comparing x and y.

I've created some code, and although = is necessary in some places, it's required in others. Could someone please clarify the differences or lead me to the appropriate resource?

For instance:

if($("#block").css.display == "none"){
  $("#block").css.display = "block";
}

The only explanation I can think of is that I'm checking in one and altering in the other. However, I am talking about equality in both.

Read Also : How to Get an Image Path from an Element in JavaScript?
Answered 3 months ago Jackson MateoJackson Mateo