JS_GetPropertyAttributes 编辑

Obsolete since JSAPI 26
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.

Get the attributes of a specified property.

Syntax

JSBool
JS_GetPropertyAttributes(JSContext *cx, JSObject *obj,
    const char *name, unsigned int *attrsp, JSBool *foundp);

JSBool
JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj,
    const jschar *name, size_t namelen,
    unsigned int *attrsp, JSBool *foundp);
NameTypeDescription
cxJSContext *The context in which to look up property attributes. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJSObject *The object that has the property to be queried.
nameconst char * or const jschar *Name of the property from which to retrieve attributes.
namelensize_t(only in JS_GetUCPropertyAttributes) The length of name in characters; or (size_t) -1 to indicate that name is null-terminated.
attrspunsigned int *Out parameter. If the specified property is found on obj, *attrsp receives its attributes.
foundpJSBool *Out parameter. If no error occurs, *foundp receives JS_TRUE if the specified property is found and JS_FALSE if it is not found. If an error occurs, the value left in *foundp is unspecified.

Description

JS_GetPropertyAttributes retrieves the property attributes of the property with the given name on a given object, obj. JS_GetUCPropertyAttributes is the Unicode version of the function.

If an error occurs, the return value is JS_FALSE, and the values left in *attrsp and *foundp are unspecified.

If obj does not have the specified property, or if it inherits it from some other object (on its prototype chain, for example), then *foundp is set to JS_FALSE. The value left in *attrsp is unspecified. The return value is JS_TRUE (to indicate that no error occurred).

If the property exists and belongs to obj, then *foundp is set to JS_TRUE, *attrsp is set to the logical OR of zero or more Property attributes flags, and the function returns JS_TRUE.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:75 次

字数:4506

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文