JS::ToPrimitive 编辑
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_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JS::HandleObject | The object to convert. |
hint | JSType | The hint to pass to the ToPrimitive and @@toPrimitive method when converting the object. hint must be JSTYPE_STRING or JSTYPE_NUMBER to pass the corresponding type as a hint, or JSTYPE_VOID to pass no hint. Do not pass any other type. |
vp | JS::MutableHandleObject | Out parameter. On success, *vp receives 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论