If condition not working properly

I am using below code the data form other page coming properly but while i am showing this in html page, the if condition is not working properly, whatever the result it going only with the if condition not in the else condition.
both the time code of if part is working.

alert("Already exit pls change!");

Please suggest.



double =, otherwise you’re not confronting the two variables, but assigning the value of the second to the first (and that always gives true as a result).

Hi guido2004 ,
Thanks its working but yesterday i used this == also but was giving the same problem,
don’t know but this time its working.

In JavaScript = means assignment and === means comparison. The == is considered to be bad practice to use as it doesn’t always return the expected result.

Hi, felgall!

As I understand it, === is a literal comparison of both type and value, whereas == is a loose comparison that will convert in order to be a more open comparitor. Right?


Yes and since you can’t always tell what type they will be converted to it is better to use the appropriate functions to convert them to the same type and use ===

As an example if you have a string and a number to compare JavaScript converts the number to a string (while the same statement in PHP would convert the string to a number and could therefore give a different result)

if (‘01’ == 1) // true in JavaScript, false in PHP