expression1
=== expression2
Where,
expression1 = A number, string, Boolean value, variable, object, array, or function.
expression2= A number, string, Boolean value, variable, object, array, or function.
Return value is boolean.
Tests two expressions for equality; the strict equality (===)operator performs in the same way as the equality (==) operator, except that data types are not converted. The result is true if 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.
Example:
// 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); // true trace(string1 === num); // false // Automatic data typing in this example converts true to "1" var string1:String = "1"; var bool1:Boolean = true; trace(string1 == bool1); // true trace(string1 === bool1); // false // Automatic data typing in this example converts false to "0" var string1:String = "0"; var bool2:Boolean = false; trace(string1 == bool2); // true trace(string1 === bool2); // false****************------**************--------*************

No comments:
Post a Comment