mozilla
Your Search Results

    JS_StrictlyEqual

    This article covers features introduced in SpiderMonkey 1.8.1

    Determine whether two JavaScript values are equal in the sense of the === operator.

    Syntax

    // Added in SpiderMonkey 45
    
    bool
    JS_StrictlyEqual(JSContext *cx, JS::Handle<JS::Value> v1, JS::Handle<JS::Value> v2,
                     bool *equal);
    
    
    // Obsolete since JSAPI 39
    
    bool
    JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, bool *equal);
    
    Name Type Description
    cx JSContext * The context in which to perform the conversion. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
    v1, v2 JS::Handle<JS::Value> / jsval The value to compare.
    equal bool * Out parameter. Receives the comparison result.

    Description

    JS_StrictlyEqual determines if v1 is strictly equal to v2 under the JavaScript === operator, as specified in ECMA 262-3 §11.9.6. If the comparison attempt was successful, the method returns true and stores the result in *equal; otherwise it returns false.

    Comparing jsvals directly in C++, as in v1 == v2, does not produce a meaningful result, since it is possible for two distinct JSStrings or jsdoubles to represent the same string or number.

    See Also

    Document Tags and Contributors

    Contributors to this page: fscholz, Waldo, Jorend, arai
    Last updated by: arai,
    Hide Sidebar