Tom said:
My Pascal background results in one type of error that I make all the time:
using "=" instead of "==" in the conditional tests of if statements.
So, i write if (a=b) ...
It doesn't do what I want, but it appears to be acceptable code. What then
does it do? Assign the value of b to a and then test if a is defined?
That depends.
In JavaScript 1.2 (NN 4.0 to 4.05), before JavaScript was fully compatible
with ECMAScript Ed. 1, it meant that the following statement was only
executed if the assignment-converted-into-a-comparison resulted in a
true-value (you still can trigger that behavior with <script
language="JavaScript1.2"> in NN 4.06+).
In later implementations that comply with ECMAScript Ed. 1 and later, it
means instead that the following statement is executed if `a' evaluates to a
true-value after the value of `b' has been assigned to it.
http://developer.mozilla.org/en/doc...n_JavaScript_Versions_and_ECMAScript_Editions
http://developer.mozilla.org/en/doc..._Assignment_within_the_conditional_expression
http://docs.sun.com/source/816-6408-10/stmt.htm#1004833
Since the implementation you are dealing with is unknown, the recommendation
is not to use the aforementioned `language' attribute (inconsistent
interpretation of its value is the reason why it was deprecated), and either
not to write assignments in `if' statements (other programming languages
such as Python have adopted this as a language rule due to the ambiguity) --
a = b;
if (a) ...
--, or to enclose the assignment in another pair of parentheses:
if ((a = b)) ...
PointedEars