Trait boa_engine::JsArgs

source ·
pub trait JsArgs {
    // Required method
    fn get_or_undefined(&self, index: usize) -> &JsValue;
}
Expand description

A utility trait to make working with function arguments easier.

Required Methods§

source

fn get_or_undefined(&self, index: usize) -> &JsValue

Utility function to get a parameter from a [JsValue] or default to JsValue::Undefined if get returns None.

Call this if you are thinking of calling something similar to args.get(n).cloned().unwrap_or_default() or args.get(n).unwrap_or(&undefined).

This returns a reference for efficiency, in case you only need to call methods of JsValue.

Implementations on Foreign Types§

source§

impl JsArgs for [JsValue]

source§

fn get_or_undefined(&self, index: usize) -> &JsValue

Implementors§