+ 1

difference between = and == ?

27th Mar 2018, 12:02 PM
Sankalp Pradhan
Sankalp Pradhan - avatar
4 Answers
+ 7
One assigns the value of RHS to a variable the other one compares the values like: var a = 9 // set a's value as 9 if ("2" == 2) alert("string 2 is equal to 2") // check if string 2 is equal to 2, it will be equal in JavaScript.
27th Mar 2018, 12:12 PM
Lord Krishna
Lord Krishna - avatar
+ 7
= is assignment operator == is reference comparison
27th Mar 2018, 1:34 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 3
@Lord Krishna sorry bro..
27th Mar 2018, 2:31 PM
Baraa AB
Baraa AB - avatar
0
= is gir assigning the item on its right to the idenifiet to its left. == tests to see if the left and right items are equal.
27th Mar 2018, 12:25 PM
josh mizzi
josh mizzi - avatar