Tuesday, June 10, 2008

assingment operator " = "

Remember, the assignment operator " = " in javascript is assigned by reference not the coppied value.
e.g var number1;
var number2 = 3 ;
number1 = number2;
number2 = 5 ;
alert(number1) ;

Guest what? 3 or 5.
The right answer is 5 not 3, since its reference has been changed to 5.

No comments: