Your test expression is a string, not a boolean expression. In JavaScript, you can compare any expression as a boolean expression, and it will be true if the expression is not null or empty. So, in your case, your JavaScript is actually just checking is the string value "1=2" exists, which is always true. If you remove the quotes, it will still be true, because then it will be an assignment, not a comparison, and the result of the assignment is the value assigned (2, in this case). What you want is something like this:
if (1===2) {
...
}
Note that I'm using a triple (or strict) equals, this makes sure that JavaScript compares the values based on their actual types without conversion. Otherwise a statement like 1=='1' will be true, even though one side is a number and the other is a string, which is usually not what you want.
Hope that helps,