js_sys::Array::index_of function

Example

Returns the first index at which a given element can be found in the array, or -1 if it is not present.


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

Function


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

features/dependencies

Source Code