Obsolete since JSAPI 44
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
This article covers features introduced in SpiderMonkey 1.8.6
JS::ToPrimitive from JSAPI 44.
bool JS_DefaultValue(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::MutableHandle<JS::Value> vp);
||The context in which to perform the conversion. Requires request. In a
||The object to convert.|
||The hint to pass to the
||Out parameter. On success,
obj, to a primitive value using that object's
[[DefaultValue]] hook. ECMAScript specifies that all objects have a
[[DefaultValue]] hook. Objects with classes defined by ECMAScript itself all use the
[[DefaultValue]] algorithm specified in §8.12.8 (but note the algorithm's special case for Date objects). Objects with a custom JSClass specified by the embedder will invoke that class's convert hook, which must convert the object to a primitive value, to determine the primitive result of conversion. Behavior when the convert hook is
JS_ConvertStub is identical to that for objects defined by ECMAScript.
JS_DefaultValue stores the converted value in
*vp and returns
true. On error or exception, it returns
false, and the value left in
*vp is undefined.