== (equality)
Previous  Top  Next

Syntax
expression1 == expression2

Arguments
expression1,expression2: A number, string, boolean value, variable or function.

Returns
Nothing.

Description
Operator (equality); tests two expressions for equality. The result is true if the expressions are equal.
The definition of equal depends on the data type of the parameter:
·Numbers and boolean values are compared by value and are considered equal if they have the same value     
·String constants are converted to numeric unless both expressions are string constants  
·Variables are assumed to be numeric. Possibly undergoing a conversion  
·Two variables are equal if they have the same numeric value.  

Sample
x = 5;
y = 6;

trace(x == y);   // returns (0), false

These examples show the results of operations that compare mixed types.
x = "5"; y = "5";
trace(x == y);   // this works as variables are converted to numbers.
// true
// this works as variables are converted to numbers.

x = "5"; y = "66";
trace(x ==y);
// false
// this works as variables are converted to numbers.

x = "chris"; y = "steve";
trace (x == y);
// true
// unexpected result caused by conversion of both strings constants to numeric (value = 0).
// use 'eq' operator instead.

See Also
eq