#[repr(transparent)]pub struct JsObject(_);
Expand description
The type of JavaScript objects, i.e., the root of all object types.
Example
// Extract the console.log function:
let console: Handle<JsObject> = cx.global().get(&mut cx, "console")?;
let log: Handle<JsFunction> = console.get(&mut cx, "log")?;
// Create an object:
let obj = cx.empty_object();
let name = cx.string("Neon");
obj.set(&mut cx, "name", name)?;
let url = cx.string("https://neon-bindings.com");
obj.set(&mut cx, "url", url)?;
// Call console.log(obj):
log.call_with(&cx).arg(obj).exec(&mut cx)?;
Implementations§
Trait Implementations§
source§impl Object for JsObject
impl Object for JsObject
source§fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K
) -> NeonResult<Option<Handle<'a, V>>>
fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Option<Handle<'a, V>>>
Gets a property from a JavaScript object that may be
undefined
and
attempts to downcast the value if it existed.source§fn get_value<'a, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K
) -> NeonResult<Handle<'a, JsValue>>
fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Handle<'a, JsValue>>
source§fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K
) -> NeonResult<Handle<'a, V>>
fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K ) -> NeonResult<Handle<'a, V>>
Gets a property from a JavaScript object and attempts to downcast as a specific type.
Equivalent to calling
obj.get_value(&mut cx)?.downcast_or_throw(&mut cx)
. Read moresource§fn get_own_property_names<'a, C: Context<'a>>(
&self,
cx: &mut C
) -> JsResult<'a, JsArray>
fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C ) -> JsResult<'a, JsArray>
Available on crate feature
napi-6
only.