Function quickjs_runtime::quickjs_utils::arrays::is_array_q

source ·
pub fn is_array_q(
    q_ctx: &QuickJsRealmAdapter,
    obj_ref: &QuickJsValueAdapter,
) -> bool
Expand description

Check whether an object is an array

§Example

use quickjs_runtime::builder::QuickJsRuntimeBuilder;
use quickjs_runtime::jsutils::Script;
use quickjs_runtime::quickjs_utils::arrays;

let rt = QuickJsRuntimeBuilder::new().build();
rt.exe_rt_task_in_event_loop(|q_js_rt| {
    let q_ctx = q_js_rt.get_main_realm();
    let obj_ref = q_ctx.eval(Script::new("is_array_test.es", "([1, 2, 3]);")).ok().expect("script failed");
    let is_array = arrays::is_array_q(q_ctx, &obj_ref);
    assert!(is_array);
});