### Class

# JavaScriptCore Value

#### Description [src]

    class JavaScriptCore.Value : GObject.Object {
      parent: GObject
    }

JSCValue represents a reference to a value in a `JSCContext`. The JSCValue protects the referenced value from being garbage collected.

#### Ancestors

- GObject

#### Constructors

###### jsc_value_new_array

Create a new `JSCValue` referencing an array with the given items. If `first_item_type` is `G_TYPE_NONE` an empty array is created.

###### jsc_value_new_array_buffer

Creates a new %ArrayBuffer from existing `data` in memory.

Available since: 2.38

###### jsc_value_new_array_from_garray

Create a new `JSCValue` referencing an array with the items from `array`. If `array` is `NULL` or empty a new empty array will be created. Elements of `array` should be pointers to a `JSCValue`.

###### jsc_value_new_array_from_strv

Create a new `JSCValue` referencing an array of strings with the items from `strv`. If `array` is `NULL` or empty a new empty array will be created.

###### jsc_value_new_boolean

Create a new `JSCValue` from `value`.

###### jsc_value_new_from_json

Create a new `JSCValue` referencing a new value created by parsing `json`.

Available since: 2.28

###### jsc_value_new_function

Create a function in `context`. If `name` is `NULL` an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), `callback` is called receiving the function parameters and then `user_data` as last parameter. When the function is cleared in `context`, `destroy_notify` is called with `user_data` as parameter.

###### jsc_value_new_function_variadic

Create a function in `context`. If `name` is `NULL` an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), `callback` is called receiving an `GPtrArray` of `JSCValue`s with the arguments and then `user_data` as last parameter. When the function is cleared in `context`, `destroy_notify` is called with `user_data` as parameter.

###### jsc_value_new_functionv

Create a function in `context`. If `name` is `NULL` an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), `callback` is called receiving the function parameters and then `user_data` as last parameter. When the function is cleared in `context`, `destroy_notify` is called with `user_data` as parameter.

###### jsc_value_new_null

Create a new `JSCValue` referencing null in `context`.

###### jsc_value_new_number

Create a new `JSCValue` from `number`.

###### jsc_value_new_object

Create a new `JSCValue` from `instance`. If `instance` is `NULL` a new empty object is created. When `instance` is provided, `jsc_class` must be provided too. `jsc_class` takes ownership of `instance` that will be freed by the `GDestroyNotify` passed to jsc_context_register_class().

###### jsc_value_new_string

Create a new `JSCValue` from `string`. If you need to create a `JSCValue` from a string containing null characters, use `jsc_value_new_string_from_bytes()` instead.

###### jsc_value_new_string_from_bytes

Create a new `JSCValue` from `bytes`.

###### jsc_value_new_typed_array

Create a new typed array containing a given amount of elements.

Available since: 2.38

###### jsc_value_new_undefined

Create a new `JSCValue` referencing undefined in `context`.

#### Instance methods

###### jsc_value_array_buffer_get_data

Gets a pointer to memory that contains the array buffer data.

Available since: 2.38

###### jsc_value_array_buffer_get_size

Gets the size in bytes of the array buffer.

Available since: 2.38

###### jsc_value_constructor_call

Invoke new with constructor referenced by `value`. If `first_parameter_type` is `G_TYPE_NONE` no parameters will be passed to the constructor.

###### jsc_value_constructor_callv

Invoke new with constructor referenced by `value`. If `n_parameters` is 0 no parameters will be passed to the constructor.

###### jsc_value_function_call

Call function referenced by `value`, passing the given parameters. If `first_parameter_type` is `G_TYPE_NONE` no parameters will be passed to the function.

###### jsc_value_function_callv

Call function referenced by `value`, passing the given `parameters`. If `n_parameters` is 0 no parameters will be passed to the function.

###### jsc_value_get_context

Get the `JSCContext` in which `value` was created.

###### jsc_value_is_array

Get whether the value referenced by `value` is an array.

###### jsc_value_is_array_buffer

Check whether the `value` is an %ArrayBuffer.

Available since: 2.38

###### jsc_value_is_boolean

Get whether the value referenced by `value` is a boolean.

###### jsc_value_is_constructor

Get whether the value referenced by `value` is a constructor.

###### jsc_value_is_function

Get whether the value referenced by `value` is a function.

###### jsc_value_is_null

Get whether the value referenced by `value` is null.

###### jsc_value_is_number

Get whether the value referenced by `value` is a number.

###### jsc_value_is_object

Get whether the value referenced by `value` is an object.

###### jsc_value_is_string

Get whether the value referenced by `value` is a string.

###### jsc_value_is_typed_array

Determines whether a value is a typed array.

Available since: 2.38

###### jsc_value_is_undefined

Get whether the value referenced by `value` is undefined.

###### jsc_value_new_typed_array_with_buffer

Create a new typed array value with elements from an array buffer.

Available since: 2.38

###### jsc_value_object_define_property_accessor

Define or modify a property with `property_name` in object referenced by `value`. When the property value needs to be getted or set, `getter` and `setter` callbacks will be called. When the property is cleared in the `JSCClass` context, `destroy_notify` is called with `user_data` as parameter. This is equivalent to JavaScript Object.defineProperty() when used with an accessor descriptor.

###### jsc_value_object_define_property_data

Define or modify a property with `property_name` in object referenced by `value`. This is equivalent to JavaScript Object.defineProperty() when used with a data descriptor.

###### jsc_value_object_delete_property

Try to delete property with `name` from `value`. This function will return `FALSE` if the property was defined without `JSC_VALUE_PROPERTY_CONFIGURABLE` flag.

###### jsc_value_object_enumerate_properties

Get the list of property names of `value`. Only properties defined with `JSC_VALUE_PROPERTY_ENUMERABLE` flag will be collected.

###### jsc_value_object_get_property

Get property with `name` from `value`.

###### jsc_value_object_get_property_at_index

Get property at `index` from `value`.

###### jsc_value_object_has_property

Get whether `value` has property with `name`.

###### jsc_value_object_invoke_method

Invoke method with `name` on object referenced by `value`, passing the given parameters. If `first_parameter_type` is `G_TYPE_NONE` no parameters will be passed to the method. The object instance will be handled automatically even when the method is a custom one registered with jsc_class_add_method(), so it should never be passed explicitly as parameter of this function.

###### jsc_value_object_invoke_methodv

Invoke method with `name` on object referenced by `value`, passing the given `parameters`. If `n_parameters` is 0 no parameters will be passed to the method. The object instance will be handled automatically even when the method is a custom one registered with jsc_class_add_method(), so it should never be passed explicitly as parameter of this function.

###### jsc_value_object_is_instance_of

Get whether the value referenced by `value` is an instance of class `name`.

###### jsc_value_object_set_property

Set `property` with `name` on `value`.

###### jsc_value_object_set_property_at_index

Set `property` at `index` on `value`.

###### jsc_value_to_boolean

Convert `value` to a boolean.

###### jsc_value_to_double

Convert `value` to a double.

###### jsc_value_to_int32

Convert `value` to a #gint32.

###### jsc_value_to_json

Create a JSON string of `value` serialization. If `indent` is 0, the resulting JSON will not contain newlines. The size of the indent is clamped to 10 spaces.

Available since: 2.28

###### jsc_value_to_string

Convert `value` to a string. Use `jsc_value_to_string_as_bytes()` instead, if you need to handle strings containing null characters.

###### jsc_value_to_string_as_bytes

Convert `value` to a string and return the results as `GBytes`. This is needed to handle strings with null characters.

###### jsc_value_typed_array_get_buffer

Obtain the %ArrayBuffer for the memory region of the typed array elements.

Available since: 2.38

###### jsc_value_typed_array_get_data

Obtains a pointer to the memory region that holds the elements of the typed array; modifications done to them will be visible to JavaScript code. If `length` is not `NULL`, the number of elements contained in the typed array are also stored in the pointed location.

Available since: 2.38

###### jsc_value_typed_array_get_length

Gets the number of elements in a typed array.

Available since: 2.38

###### jsc_value_typed_array_get_offset

Gets the offset over the underlying array buffer data.

Available since: 2.38

###### jsc_value_typed_array_get_size

Gets the size of a typed array.

Available since: 2.38

###### jsc_value_typed_array_get_type

Gets the type of elements contained in a typed array.

Available since: 2.38

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### JavaScriptCore.Value:context

The `JSCContext` in which the value was created.

#### Signals

##### Signals inherited from GObject (1)

###### GObject.Object::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct JavaScriptCoreValueClass {
      GObjectClass parent_class;
      void (* _jsc_reserved0) (
    void
      );
      void (* _jsc_reserved1) (
    void
      );
      void (* _jsc_reserved2) (
    void
      );
      void (* _jsc_reserved3) (
    void
      );

    }

###### Class members

`parent_class` |
    GObjectClass
| No description available.
`_jsc_reserved0` |
    void (* _jsc_reserved0) (
    void
      )
| No description available.
`_jsc_reserved1` |
    void (* _jsc_reserved1) (
    void
      )
| No description available.
`_jsc_reserved2` |
    void (* _jsc_reserved2) (
    void
      )
| No description available.
`_jsc_reserved3` |
    void (* _jsc_reserved3) (
    void
      )
| No description available.