Platforms to show: All Mac Windows Linux Cross-Platform

Back to JSObjectMBS class.

JSObjectMBS.CallAsConstructor(arguments() as JSValueMBS, byref JSException as JSValueMBS) as JSValueMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calls an object as a constructor.

self: The JSObject to call as a constructor.
arguments: A JSValueMBS array of arguments to pass to the constructor.
JSException A pointer to a JSValueMBS in which to store an exception, if any.
Returns the JSObject that results from calling object as a constructor, or nil if an exception is thrown or object is not a constructor.

JSObjectMBS.CallAsFunction(thisObject as JSValueMBS, arguments() as JSValueMBS, byref JSException as JSValueMBS) as JSValueMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calls an object as a function.

self: The JSObject to call as a function.
thisObject: The object to use as "this," or nil to use the global object as "this."
arguments: A JSValueMBS array of arguments to pass to the function.
JSException: A JSValueMBS in which to store an exception, if any.

Returns the JSValue that results from calling object as a function, or nil if an exception is thrown or object is not a function.

JSObjectMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The private constructor.

JSObjectMBS.DeleteProperty(name as string, byref JSException as JSValueMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Deletes a property from an object.
Example
dim c as new JSContextMBS

dim v as JSObjectMBS = c.globalObject
dim e as JSValueMBS

v.SetProperty "Hello", c.valueWithString("World"), e
v.SetProperty "Value", c.valueWithDouble(5), e

MsgBox v.JSONString

call v.DeleteProperty "Hello", e

MsgBox v.JSONString

Name: A string containing the property's name.
JSException: A JSValueMBS in which to store an exception, if any.
Returns true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).

JSObjectMBS.GetProperty(name as string, byref JSException as JSValueMBS) as JSValueMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets a property from an object.
Example
dim c as new JSContextMBS

dim v as JSObjectMBS = c.globalObject
dim e as JSValueMBS

v.SetProperty "Hello", c.valueWithString("World"), e

MsgBox v.GetProperty("Hello", e).StringValue

object: The JSObject whose property you want to get.
Name: A string containing the property's name.
JSException: A JSValueMBS in which to store an exception, if any.
Returns the property's value if object has the property, otherwise the undefined value.

JSObjectMBS.GetPropertyAtIndex(propertyIndex as Integer, byref JSException as JSValueMBS) as JSValueMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets a property from an object by numeric index.
Example
dim c as new JSContextMBS

dim v as JSValueMBS = c.valueWithJSON("[1,2,3]")
dim o as JSObjectMBS = JSObjectMBS(v) // arrays are objects

dim e as JSValueMBS
dim p as JSValueMBS = o.GetProperty("length", e)

MsgBox "Length: "+p.StringValue

dim n as JSValueMBS = o.GetPropertyAtIndex(2, e)
MsgBox "3rd value in array: "+n.StringValue

The JSObject whose property you want to get.
propertyIndex: An integer value that is the property's name.
JSException: A JSValueMBS in which to store an exception, if any.

Returns the property's value if object has the property, otherwise the undefined value.

Calling GetPropertyAtIndex is equivalent to calling GetProperty with a string containing propertyIndex, but GetPropertyAtIndex provides optimized access to numeric properties.

JSObjectMBS.HasProperty(name as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Tests whether an object has a given property.
Example
dim c as new JSContextMBS

dim e as JSValueMBS
dim v as JSObjectMBS = c.NewArray(nil, e)
MsgBox str(v.HasProperty("length"))

name: A string containing the property's name.
Returns true if the object has a property whose name matches propertyName, otherwise false.

JSObjectMBS.PropertyNames as String()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Gets the names of an object's enumerable properties.
Example
dim c as new JSContextMBS

dim v as JSObjectMBS = c.globalObject
dim e as JSValueMBS

v.SetProperty "Hello", c.valueWithString("World"), e
v.SetProperty "Value", c.valueWithDouble(5), e

MsgBox Join(v.PropertyNames, EndOfLine)

JSObjectMBS.SetProperty(name as string, value as JSValueMBS, byref JSException as JSValueMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets a property on an object.
Example
dim c as new JSContextMBS

dim v as JSObjectMBS = c.globalObject
dim e as JSValueMBS

v.SetProperty "Hello", c.valueWithString("World"), e
v.SetProperty "Value", c.valueWithDouble(5), e

Name: A string containing the property's name.
Value: A JSValue to use as the property's value.
JSException A pointer to a JSValueRef in which to store an exception, if any.

JSObjectMBS.SetPropertyAtIndex(propertyIndex as Integer, value as JSValueMBS, byref JSException as JSValueMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript MBS MacFrameworks Plugin 15.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets a property on an object by numeric index.

propertyIndex: The property's name as a number.
value: A JSValue to use as the property's value.
exception: A JSValueMBS in which to store an exception, if any.

Calling SetPropertyAtIndex is equivalent to calling SetProperty with a string containing propertyIndex, but SetPropertyAtIndex provides optimized access to numeric properties.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...