The basic format of the assignment operator is:
x = 6;
The assignment operator can also be stacked to create simultaneous assignments.
x = y = z = 6;
Multiple assignment operators are evaluated from right to left.
y = (x = 3) + 4;
the value 3 is assigned to the variable x, which is then added to the value 4 and assigned to the variable y.
Once the expression is fully evaluated, y will contain the value 7.
<html>
<SCRIPT LANGUAGE="JavaScript">
<!--
x = 1;
y = 2;
z = 3;
document.write("<U>After single assignment</U><BR>");
document.write("x=",x,"<BR>y=",y,"<BR>z=",z,"<BR>");
document.write("<U>After multiple assignment</U><BR>");
document.write("x=",x,"<BR>y=",y,"<BR>z=",z,"<BR>");
x = (y = 17) + (2 * (z = 2));
document.write("<U>After multiple assignment in one expression</U><BR>");
document.write("x=",x,"<BR>y=",y,"<BR>z=",z,"<BR>");
// -->
</SCRIPT>
</html>