js_sys::Array::set function

Example

Sets an element at the specified index and enlarges the array if the index is out of range.


pub fn array_set() {
    web_sys::console::log_1(&"Start".into());
    let arr = js_sys::Array::new_with_length(3);
    arr.set(0,JsValue::from_f64(1.0));    
    arr.set(1,JsValue::from_f64(2.0));    
    arr.set(2,JsValue::from_f64(3.0));    
    web_sys::console::log(&arr);
}
                                    

Function


            pub fn set(&self, index: u32, value: JsValue)
           

features/dependencies

Source Code