JS_HasInstance 编辑
JSAPI method equivalent to the instanceof operator in JavaScript.
Syntax
bool
JS_HasInstance(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<JS::Value> v, bool *bp);
Name | Type | Description |
---|---|---|
cx | JSContext * | Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JS::Handle<JSObject*> | Constructor/prototype to test. |
v | JS::Handle<JS::Value> | The value to test. |
bp | bool * | Out parameter. On success, *bp receives the result of the test. |
Description
JS_HasInstance
determines if a specified JS value,
, is an instance of JS object, v
obj
. This function is equivalent to v instanceof obj
test in JavaScript. On success, JS_HasInstance
stores the result of the instanceof test in *bp
and returns true
. On error or exception, it returns false
, and the value left in *bp
is undefined.
When providing a prototype as obj
, the prototype's JSClass
must have its hasInstance
method set. Otherwise JS_HasInstance
returns false
.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论