This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
Checks for syntax errors in a string of JavaScript.
ctx The execution context to use.
script A JSString containing the script to check for syntax errors.
sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
@result true if the script is syntactically correct, otherwise false.
Creates a JavaScript class suitable for use with JSObjectMake.
definition A JSClassDefinition that defines the class.
@result A JSClass with the given definition. Ownership follows the Create Rule.
Creates a JavaScript context group.
@result The created JSContextGroup.
@discussion A JSContextGroup associates JavaScript contexts with one another.
Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging
JavaScript objects between contexts in different groups will produce undefined behavior.
When objects from the same context group are used in multiple threads, explicit
synchronization is required.
Evaluates a string of JavaScript.
ctx The execution context to use.
script A JSString containing the script to evaluate.
thisObject The object to use as "this," or NULL to use the global object as "this."
sourceURL A JSString containing a URL for the script's source file. This is used by debuggers and when reporting exceptions. Pass NULL if you do not care to include source file information.
startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The JSValue that results from evaluating script, or NULL if an exception is thrown.
Performs a JavaScript garbage collection.
ctx The execution context to use.
@discussion JavaScript values that are on the machine stack, in a register,
protected by JSValueProtect, set as the global object of an execution context,
or reachable from any such value will not be collected.
Gets a copy of the name of a context.
ctx The JSGlobalContext whose name you want to get.
@result The name for ctx.
@discussion A JSGlobalContext's name is exposed for remote debugging to make it
easier to identify the context you would like to attach to.
Creates a global JavaScript execution context.
globalObjectClass The class to use when creating the global object. Pass
NULL to use the default object class.
@result A JSGlobalContext with a global object of class globalObjectClass.
@discussion JSGlobalContextCreate allocates a global object and populates it with all the
built-in JavaScript objects, such as Object, Function, String, and Array.
Creates a global JavaScript execution context in the context group provided.
group The context group to use. The created global context retains the group.
Pass NULL to create a unique group for the context.
globalObjectClass The class to use when creating the global object. Pass
NULL to use the default object class.
@result A JSGlobalContext with a global object of class globalObjectClass and a context
group equal to group.
@discussion JSGlobalContextCreateInGroup allocates a global object and populates it with
all the built-in JavaScript objects, such as Object, Function, String, and Array.
Calls an object as a constructor.
ctx The execution context to use.
object The JSObject to call as a constructor.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
Calls an object as a function.
ctx The execution context to use.
object The JSObject to call as a function.
thisObject The object to use as "this," or NULL to use the global object as "this."
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
Gets the names of an object's enumerable properties.
ctx The execution context to use.
object The object whose property names you want to get.
@result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.
Deletes a property from an object.
ctx The execution context to use.
object The JSObject whose property you want to delete.
propertyName A JSString containing the property's name.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
MacOS 10.15, iOS 13.0
Deletes a property from an object using a JSValueRef as the property key.
ctx The execution context to use.
object The JSObject whose property you want to delete.
propertyKey A JSValueRef containing the property key to use when looking up the property.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
@discussion This function is the same as performing "delete objectpropertyKey" from JavaScript.
MacOS 10.12, iOS 10.0
Returns the number of bytes in a JavaScript data object.
ctx The execution context to use.
object The JS Arary Buffer object whose length in bytes to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The number of bytes stored in the data object.
MacOS 10.12, iOS 10.0
Returns a pointer to the data buffer that serves as the backing store for a JavaScript Typed Array object.
object The Array Buffer object whose internal backing store pointer to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object.
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
Gets an object's private data.
object A JSObject whose private data you want to get.
@result A void* that is the object's private data, if the object has private data, otherwise NULL.
Gets a property from an object.
ctx The execution context to use.
object The JSObject whose property you want to get.
propertyName A JSString containing the property's name.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The property's value if object has the property, otherwise the undefined value.
Gets a property from an object by numeric index.
ctx The execution context to use.
object The JSObject whose property you want to get.
propertyIndex An integer value that is the property's name.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The property's value if object has the property, otherwise the undefined value.
@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
MacOS 10.15, iOS 13.0
Gets a property from an object using a JSValueRef as the property key.
ctx The execution context to use.
object The JSObject whose property you want to get.
propertyKey A JSValueRef containing the property key to use when looking up the property.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The property's value if object has the property key, otherwise the undefined value.
@discussion This function is the same as performing "objectpropertyKey" from JavaScript.
Gets an object's prototype.
ctx The execution context to use.
object A JSObject whose prototype you want to get.
@result A JSValue that is the object's prototype.
MacOS 10.12, iOS 10.0
Returns the JavaScript Array Buffer object that is used as the backing of a JavaScript Typed Array object.
ctx The execution context to use.
object The JSObjectRef whose Typed Array type data pointer to obtain.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.
MacOS 10.12, iOS 10.0
Returns the byte length of a JavaScript Typed Array object.
ctx The execution context to use.
object The Typed Array object whose byte length to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The byte length of the Typed Array object or 0 if the object is not a Typed Array object.
MacOS 10.12, iOS 10.0
Returns the byte offset of a JavaScript Typed Array object.
ctx The execution context to use.
object The Typed Array object whose byte offset to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The byte offset of the Typed Array object or 0 if the object is not a Typed Array object.
MacOS 10.12, iOS 10.0
Returns a temporary pointer to the backing store of a JavaScript Typed Array object.
ctx The execution context to use.
object The Typed Array object whose backing store pointer to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object.
@discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
MacOS 10.12, iOS 10.0
Returns the length of a JavaScript Typed Array object.
ctx The execution context to use.
object The Typed Array object whose length to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The length of the Typed Array object or 0 if the object is not a Typed Array object.
Tests whether an object has a given property.
object The JSObject to test.
propertyName A JSString containing the property's name.
@result true if the object has a property whose name matches propertyName, otherwise false.
MacOS 10.15, iOS 13.0
Tests whether an object has a given property using a JSValueRef as the property key.
object The JSObject to test.
propertyKey A JSValueRef containing the property key to use when looking up the property.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result true if the object has a property whose name matches propertyKey, otherwise false.
@discussion This function is the same as performing "propertyKey in object" from JavaScript.
Tests whether an object can be called as a constructor.
ctx The execution context to use.
object The JSObject to test.
@result true if the object can be called as a constructor, otherwise false.
Tests whether an object can be called as a function.
ctx The execution context to use.
object The JSObject to test.
@result true if the object can be called as a function, otherwise false.
Creates a JavaScript object.
ctx The execution context to use.
jsClass The JSClass to assign to the object. Pass NULL to use the default object class.
data A void* to set as the object's private data. Pass NULL to specify no private data.
@result A JSObject with the given class and private data.
@discussion The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data.
Creates a JavaScript Array object.
ctx The execution context to use.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObject that is an Array.
@discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
is supplied, this function returns an array with one element.
MacOS 10.12, iOS 10.0
Creates a JavaScript Array Buffer object from an existing pointer.
ctx The execution context to use.
bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object.
byteLength The number of bytes pointed to by the parameter bytes.
bytesDeallocator The allocator to use to deallocate the external buffer when the Typed Array data object is deallocated.
deallocatorContext A pointer to pass back to the deallocator.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
Convenience method for creating a JavaScript constructor.
ctx The execution context to use.
jsClass A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class.
callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor.
@result A JSObject that is a constructor. The object's prototype will be the default object prototype.
@discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data. If the constructor is inherited via JS subclassing and the value returned from callAsConstructor was created with jsClass, then the returned object will have it's prototype overridden to the derived class's prototype.
Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
ctx The execution context to use.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObject that is a Date.
MacOS 10.15, iOS 13.0
Creates a JavaScript promise object by invoking the provided executor.
ctx The execution context to use.
resolve A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
reject A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObject that is a promise or NULL if an exception occurred.
Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
ctx The execution context to use.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObject that is an Error.
Creates a function with a given script as its body.
ctx The execution context to use.
name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
parameterCount An integer count of the number of parameter names in parameterNames.
parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
body A JSString containing the script to use as the function's body.
sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
@result A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype.
@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
Convenience method for creating a JavaScript function with a given callback as its implementation.
ctx The execution context to use.
name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called.
@result A JSObject that is a function. The object's prototype will be the default function prototype.
Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
ctx The execution context to use.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObject that is a RegExp.
MacOS 10.12, iOS 10.0
Creates a JavaScript Typed Array object with the given number of elements.
ctx The execution context to use.
arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
length The number of elements to be in the new Typed Array.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.
MacOS 10.12, iOS 10.0
Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object.
ctx The execution context to use.
arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
MacOS 10.12, iOS 10.0
Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object with the given offset and length.
ctx The execution context to use.
arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
byteOffset The byte offset for the created Typed Array. byteOffset should aligned with the element size of arrayType.
length The number of elements to include in the Typed Array.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
MacOS 10.12, iOS 10.0
Creates a JavaScript Typed Array object from an existing pointer.
ctx The execution context to use.
arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object.
byteLength The number of bytes pointed to by the parameter bytes.
bytesDeallocator The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated.
deallocatorContext A pointer to pass back to the deallocator.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
@discussion If an exception is thrown during this function the bytesDeallocator will always be called.
Sets a pointer to private data on an object.
object The JSObject whose private data you want to set.
data A void* to set as the object's private data.
@result true if object can store private data, otherwise false.
@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
Sets a property on an object.
ctx The execution context to use.
object The JSObject whose property you want to set.
propertyName A JSString containing the property's name.
value A JSValueRef to use as the property's value.
attributes A logically ORed set of JSPropertyAttributes to give to the property.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Sets a property on an object by numeric index.
ctx The execution context to use.
object The JSObject whose property you want to set.
propertyIndex The property's name as a number.
value A JSValue to use as the property's value.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
MacOS 10.15, iOS 13.0
Sets a property on an object using a JSValueRef as the property key.
ctx The execution context to use.
object The JSObject whose property you want to set.
propertyKey A JSValueRef containing the property key to use when looking up the property.
value A JSValueRef to use as the property's value.
attributes A logically ORed set of JSPropertyAttributes to give to the property.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@discussion This function is the same as performing "objectpropertyKey = value" from JavaScript.
Sets an object's prototype.
ctx The execution context to use.
object The JSObject whose prototype you want to set.
value A JSValue to set as the object's prototype.
Adds a property name to a JavaScript property name accumulator.
accumulator The accumulator object to which to add the property name.
propertyName The property name to add.
Gets a count of the number of items in a JavaScript property name array.
array The array from which to retrieve the count.
@result An integer count of the number of names in array.
Gets a property name at a given index in a JavaScript property name array.
array The array from which to retrieve the property name.
index The index of the property name to retrieve.
@result A JSStringRef containing the property name.
Creates a JavaScript string from a buffer of Unicode characters.
chars The buffer of Unicode characters to copy into the new JSString.
numChars The number of characters to copy from the buffer pointed to by chars.
@result A JSString containing chars. Ownership follows the Create Rule.
Creates a JavaScript string from a null-terminated UTF8 string.
string The null-terminated UTF8 string to copy into the new JSString.
@result A JSString containing string. Ownership follows the Create Rule.
Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string.
string The JSString whose backing store you want to access.
@result A pointer to the Unicode character buffer that serves as string's backing store, which will be deallocated when string is deallocated.
Returns the number of Unicode characters in a JavaScript string.
string The JSString whose length (in Unicode characters) you want to know.
@result The number of Unicode characters stored in string.
Returns the maximum number of bytes a JavaScript string will take up if converted into a null-terminated UTF8 string.
string The JSString whose maximum converted size (in bytes) you want to know.
@result The maximum number of bytes that could be required to convert string into a
null-terminated UTF8 string. The number of bytes that the conversion actually ends
up requiring could be less than this, but never more.
Converts a JavaScript string into a null-terminated UTF8 string,
and copies the result into an external byte buffer.
string The source JSString.
buffer The destination byte buffer into which to copy a null-terminated
UTF8 representation of string. On return, buffer contains a UTF8 string
representation of string. If bufferSize is too small, buffer will contain only
partial results. If buffer is not at least bufferSize bytes in size,
behavior is undefined.
bufferSize The size of the external buffer in bytes.
@result The number of bytes written into buffer (including the null-terminator byte).
Tests whether two JavaScript strings match.
a The first JSString to test.
b The second JSString to test.
@result true if the two strings match, otherwise false.
Tests whether a JavaScript string matches a null-terminated UTF8 string.
a The JSString to test.
b The null-terminated UTF8 string to test.
@result true if the two strings match, otherwise false.
Creates a JavaScript string containing the JSON serialized representation of a JS value.
ctx The execution context to use.
value The value to serialize.
indent The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSString with the result of serialization, or NULL if an exception is thrown.
Returns a JavaScript value's type.
ctx The execution context to use.
value The JSValue whose type you want to obtain.
@result A value of type JSType that identifies value's type.
MacOS 10.12, iOS 10.0
Returns a JavaScript value's Typed Array type.
ctx The execution context to use.
value The JSValue whose Typed Array type to return.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
MacOS 10.11, iOS 9.0
Tests whether a JavaScript value is an array.
ctx The execution context to use.
value The JSValue to test.
@result true if value is an array, otherwise false.
Tests whether a JavaScript value's type is the boolean type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the boolean type, otherwise false.
MacOS 10.11, iOS 9.0
Tests whether a JavaScript value is a date.
ctx The execution context to use.
value The JSValue to test.
@result true if value is a date, otherwise false.
Tests whether two JavaScript values are equal, as compared by the JS == operator.
ctx The execution context to use.
a The first value to test.
b The second value to test.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result true if the two values are equal, false if they are not equal or an exception is thrown.
Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
ctx The execution context to use.
value The JSValue to test.
constructor The constructor to test against.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.
Tests whether a JavaScript value's type is the null type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the null type, otherwise false.
Tests whether a JavaScript value's type is the number type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the number type, otherwise false.
Tests whether a JavaScript value's type is the object type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the object type, otherwise false.
Tests whether a JavaScript value is an object with a given class in its class chain.
ctx The execution context to use.
value The JSValue to test.
jsClass The JSClass to test against.
@result true if value is an object and has jsClass in its class chain, otherwise false.
Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
ctx The execution context to use.
a The first value to test.
b The second value to test.
@result true if the two values are strict equal, otherwise false.
Tests whether a JavaScript value's type is the string type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the string type, otherwise false.
MacOS 10.15, iOS 13.0
Tests whether a JavaScript value's type is the symbol type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the symbol type, otherwise false.
Tests whether a JavaScript value's type is the undefined type.
ctx The execution context to use.
value The JSValue to test.
@result true if value's type is the undefined type, otherwise false.
Creates a JavaScript value of the boolean type.
ctx The execution context to use.
boolean The bool to assign to the newly created JSValue.
@result A JSValue of the boolean type, representing the value of boolean.
Creates a JavaScript value from a JSON formatted string.
ctx The execution context to use.
string The JSString containing the JSON string to be parsed.
@result A JSValue containing the parsed value, or NULL if the input is invalid.
Creates a JavaScript value of the number type.
ctx The execution context to use.
number The double to assign to the newly created JSValue.
@result A JSValue of the number type, representing the value of number.
Creates a JavaScript value of the string type.
ctx The execution context to use.
string The JSString to assign to the newly created JSValue. The
newly created JSValue retains string, and releases it upon garbage collection.
@result A JSValue of the string type, representing the value of string.
MacOS 10.15, iOS 13.0
Creates a JavaScript value of the symbol type.
ctx The execution context to use.
description A description of the newly created symbol value.
@result A unique JSValue of the symbol type, whose description matches the one provided.
Protects a JavaScript value from garbage collection.
ctx The execution context to use.
value The JSValue to protect.
@discussion Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.
Converts a JavaScript value to boolean and returns the resulting boolean.
ctx The execution context to use.
value The JSValue to convert.
@result The boolean result of conversion.
Converts a JavaScript value to number and returns the resulting number.
ctx The execution context to use.
value The JSValue to convert.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The numeric result of conversion, or NaN if an exception is thrown.
JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception);
Converts a JavaScript value to object and returns the resulting object.
ctx The execution context to use.
value The JSValue to convert.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result The JSObject result of conversion, or NULL if an exception is thrown.
Converts a JavaScript value to string and copies the result into a JavaScript string.
ctx The execution context to use.
value The JSValue to convert.
exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
Unprotects a JavaScript value from garbage collection.
ctx The execution context to use.
value The JSValue to unprotect.
@discussion A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.
JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value);
The callback invoked when an object is used as a constructor in a 'new' expression.
ctx The execution context to use.
constructor A JSObject that is the constructor being called.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of the arguments passed to the function.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSObject that is the constructor's return value.
@discussion If you named your function CallAsConstructor, you would declare it like this:
The callback invoked when an object is called as a function.
ctx The execution context to use.
function A JSObject that is the function being called.
thisObject A JSObject that is the 'this' variable in the function's scope.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of the arguments passed to the function.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSValue that is the function's return value.
@discussion If you named your function CallAsFunction, you would declare it like this:
The callback invoked when converting an object to a particular JavaScript type.
ctx The execution context to use.
object The JSObject to convert.
type A JSType specifying the JavaScript type to convert to.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result The objects's converted value, or NULL if the object was not converted.
@discussion If you named your function ConvertToType, you would declare it like this:
The callback invoked when deleting a property.
ctx The execution context to use.
object The JSObject in which to delete the property.
propertyName A JSString containing the name of the property to delete.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if propertyName was successfully deleted, otherwise false.
@discussion If you named your function DeleteProperty, you would declare it like this:
The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
object The JSObject being finalized.
@discussion If you named your function Finalize, you would declare it like this:
The callback invoked when getting a property's value.
ctx The execution context to use.
object The JSObject to search for the property.
propertyName A JSString containing the name of the property to get.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result The property's value if object has the property, otherwise NULL.
@discussion If you named your function GetProperty, you would declare it like this:
The callback invoked when collecting the names of an object's properties.
ctx The execution context to use.
object The JSObject whose property names are being collected.
propertyNames A JavaScript property name accumulator in which to accumulate the names of object's properties.
@discussion If you named your function GetPropertyNames, you would declare it like this:
hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
ctx The execution context to use.
constructor The JSObject that is the target of the 'instanceof' expression.
possibleInstance The JSValue being tested to determine if it is an instance of constructor.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if possibleInstance is an instance of constructor, otherwise false.
@discussion If you named your function HasInstance, you would declare it like this:
The callback invoked when determining whether an object has a property.
ctx The execution context to use.
object The JSObject to search for the property.
propertyName A JSString containing the name of the property look up.
@result true if object has the property, otherwise false.
@discussion If you named your function HasProperty, you would declare it like this:
The callback invoked when an object is first created.
ctx The execution context to use.
object The JSObject being created.
@discussion If you named your function Initialize, you would declare it like this:
The callback invoked when setting a property's value.
ctx The execution context to use.
object The JSObject on which to set the property's value.
propertyName A JSString containing the name of the property to set.
value A JSValue to use as the property's value.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if the property was set, otherwise false.
@discussion If you named your function SetProperty, you would declare it like this:
JSTypedArrayBytesDeallocator A function used to deallocate bytes passed to a Typed Array constructor. The function should take two arguments. The first is a pointer to the bytes that were originally passed to the Typed Array constructor. The second is a pointer to additional information desired at the time the bytes are to be freed.