Mozilla.com

Table of contents
  1. 1. Syntax
  2. 2. Description
  3. 3. See Also

JS_HasProperty

Table of contents
  1. 1. Syntax
  2. 2. Description
  3. 3. See Also

Determine whether a JavaScript object has a specified property.

Syntax

JSBool JS_HasProperty(JSContext *cx, JSObject *obj,
   const char *name, JSBool *foundp);

JSBool JS_HasUCProperty(JSContext *cx, JSObject *obj,
   const jschar *name, size_t namelen, JSBool *foundp);


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 JSObject * Object to search on for the property.
name const char * or const jschar * Name of the property to look up.
namelen size_t (only in JS_HasUCProperty) The length of name in characters, or -1 to indicate that name is null-terminated.
foundp JSBool * Non-null pointer to a variable of type JSBool. On success, JS_HasProperty stores JS_TRUE in this variable if obj has a property with the given name, and JS_FALSE if not.

Description

JS_HasProperty examines a specified JS object, obj, its scope and prototype links, for a property with the specified name. JS_HasUCProperty is the corresponding Unicode API.

If the property exists, this function sets *foundp to JS_TRUE and returns JS_TRUE.

If the object obj has no such property, the function sets *foundp to JS_FALSE and returns JS_TRUE (to indicate that no error occurred).

If an error occurs during the search, the function returns JS_FALSE, and the value of *foundp is undefined.

Page last modified 20:11, 21 Aug 2008 by Jorend

Files (0)