Applies to TestComplete 14.70, last modified on October 26, 2020

The equal function compares two expressions to determine if they are equal, and returns true or false. If the compared expressions are not of the same type, TestComplete attempts to convert them to the same type (such as string, number, or boolean) before the comparison.

Declaration

equal(ab) Parameters
a [in] Required Variant
b [in] Required Variant
Result     Boolean  

Description

Due to JavaScript specifics, the equality operator == may return a wrong result if at least one of the compared values has been obtained from a TestComplete object or a COM object. For example, when you compare properties of objects in your tested application. To avoid comparison errors, use equal(a, b) instead of a==b, and !equal(a, b) instead of a!=b.

Parameters

a, b

The expressions to compare.

Result

true if the compared expressions are equal, otherwise, false.

Example

JavaScript

equal(2, 2)            // true
equal(2, 2.0)          // true
equal(2, "2")          // true
equal(1, true)        // true
equal(0, false)        // true
equal(0, null)        // false
equal(0, undefined)    // false
equal(null, undefined) // true

See Also

strictEqual Function
JavaScript - Specifics of Usage

Highlight search results