Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
= for assigning value to variable
== for comparing to values in if conditions
= assign a value to variable
== equal (equal for value)
=== identical (equal for value and data type)
The == (Equality) operator will compare for equality after doing any necessary type conversions.
The "=" is an Assignment operator, it assign the value of the right hand operand to left hand operand
e.g
var Name="Samer Saleh";
var What_is_my_name=Name;
What_is_my_Name now holds the value of the Name, depending on the type of value, sometimes it might contain other than a value, sometimes it can also act as a reference to another variable;
e.g
var x=[1,2,4] var y;
y=x;
x.push(5);
On the other hand "==" is a logical operation it compares two operands
e.g var a=2, var b=3; (a == b) will yield to false, however "==" does a type conversion before comparing the value, this can lead to undesired effect, "===" is prefered in the JavaScript community because it operates in operand of the same type and is faster than the previous.
' == ' is a reference comparison and ' = ' to evaluate the comparison of values in the objects.
"=" is used to assign value to variable where as "==" used to compare the values.
= is an "Assignment Operator".
example var a = 53;
== is used for comparison. It is a comparison Operator
example if a ==b
the operarion (=) used to set values or variables to variables.
example a =3 , a = text1.value.
the operation (==) used to compare2 variable or values.
example a == b, a==2 , >, <, >=, =<, ....etc
As all answer above mentiond "=" is assignment operator that assign the value of any variable, reference etc.
"==" is equality operator that check the value of right hand to left hand the result will be the boolean value.
"=" is an assign operator that assigns right operand to left operand.
"==" is a comparison operator that check if both right and left operands are equal in value or not.
"===" is a comparison operator that check if both right and left operands are equal in both value and data type or not.
Here's you will find everything about Comparison Operators in details.
Hope this helps.
Mahmoud, Cheers