js_sys::Array::delete function

Example

Set the element at the index to undefined. The array is not resized and stays the same length. If the index is out of range, the function does nothing.


#[wasm_bindgen]
pub fn array_delete() {
    let arr = js_sys::Array::new();
    arr.push(&JsValue::from("John"));
    arr.push(&JsValue::from("Jane"));    
    arr.push(&JsValue::from("James"));    
    web_sys::console::log_2(&"Array Length: %d".into(),&JsValue::from(arr.length()));
    arr.delete(1);
    web_sys::console::log_2(&"Array Length: %d".into(),&JsValue::from(arr.length()));
    web_sys::console::log_2(&"Array Item 1: %s".into(),&arr.get(0));
    web_sys::console::log_2(&"Array Item 2: %s".into(),&arr.get(1));
    web_sys::console::log_2(&"Array Item 3: %s".into(),&arr.get(2));                    
}
                                    

Function


            pub fn delete(&self, index: u32)
           

features/dependencies

Source Code