js_sys::Array::last_index_of function

Example

Returns the last index of an element found in the array, searching backwards, starting at fromIndex. A value of -1 is returned if the element is not found.


pub fn array_last_index_of() {
    let arr = js_sys::Array::new();
    arr.push(&JsValue::from("Jane"));    
    arr.push(&JsValue::from("John"));
    arr.push(&JsValue::from("Jane"));    
    arr.push(&JsValue::from("James"));
    let idx=arr.last_index_of(&JsValue::from("Jane"),1);   
    web_sys::console::log_2(&"Index Found : %d ".into(),&JsValue::from(idx));
    //Index Found : 0
}                                      
                

Function


            pub fn last_index_of(&self, value: &JsValue, from_index: i32) -> i32
           

features/dependencies

Source Code