=== (strict equality)
Availability
Flash Player 6.
Usage
expression1 === expression2
Returns
A Boolean value.
Description
Operator; tests two expressions for equality; the strict equality (
way as the equality (
information, see "Automatic data typing" in Using ActionScript in Flash.) The result is
both expressions, including their data types, 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 expressions are equal if they have the same number of characters and the characters
are identical.
•
Variables representing objects, arrays, and functions are compared by reference. Two such
variables are equal if they refer to the same object, array, or function. Two separate arrays are
never considered equal, even if they have the same number of elements.
For more information, see "Operator precedence and associativity" in Using ActionScript in Flash.
Example
The comments in the following code show the returned value of operations that use the equality
and strict equality operators:
// Both return true because no conversion is done
var string1:String = "5";
var string2:String = "5";
trace(string1 == string2); // true
trace(string1 === string2); // true
// Automatic data typing in this example converts 5 to "5"
var string1:String = "5";
var num:Number = 5;
trace(string1 == num);
trace(string1 === num);
// Automatic data typing in this example converts true to "1"
var string1:String = "1";
var bool1:Boolean = true;
trace(string1 == bool1);
trace(string1 === bool1);
) operator, except that data types are not converted. (For more
==
// true
// false
// true
// false
)operator performs in the same
===
=== (strict equality)
if
true
83
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers