May 2, 2002 - The Risk of Un-typed Variables
![]() |
May 2, 2002 The Risk of Un-typed Variables Tips: May 2002
Yehuda Shiran, Ph.D.
|
var x, y, z;
x = "2";
y = 2;
z = x + y;
What do you think the value of z will be? Since we did not declare the types of x and y, the compiler casts one of them to the other. In the case above, z will be 22. The variable y is casted to String and concatenated with x.To learn more on JScript .NET, go to Column 108, JScript .NET, Part II: Major Features.



