This article covers features introduced in SpiderMonkey 45
Converts a JavaScript object to a primitive value, using the semantics of ToPrimitive.
Syntax
bool
JS::ToPrimitive(JSContext *cx, JS::HandleObject obj, JSType hint,
                JS::MutableHandleValue vp);
| Name | Type | Description | 
|---|---|---|
| cx | JSContext * | The context in which to perform the conversion. Requires request. In a JS_THREADSAFEbuild, the caller must be in a request on thisJSContext. | 
| obj | JS::HandleObject | The object to convert. | 
| hint | JSType | The hint to pass to the ToPrimitiveand@@toPrimitivemethod when converting the object.hintmust beJSTYPE_STRINGorJSTYPE_NUMBERto pass the corresponding type as a hint, orJSTYPE_VOIDto pass no hint. Do not pass any other type. | 
| vp | JS::MutableHandleObject | Out parameter. On success, *vpreceives the converted value. | 
Description
JS::ToPrimitive converts a JavaScript object, obj, to a primitive value using ECMAScript 6 ToPrimitive.
On success, JS::ToPrimitive stores the converted value in *vp and returns true. On error or exception, it returns false, and the value left in *vp is undefined.
See Also
- MXR ID Search for JS::ToPrimitive
- JS::GetFirstArgumentAsTypeHint
- JS_DefaultValue-- old name of this function
- bug 1054756 - added