What's the arr.splice here doing in this Typescript code?
export function removeIfPresent<T>(arr: T[] | undefined, item: T) {
    if (!arr) {
        return;
    }
    const index = arr.indexOf(item);
    if (index !== -1) {
        arr.splice(index, 1);
    }
}
system
is tipscript code main yahan kya kar rahaa he.
niryaat fnction remastifpresent <t> (arr: t [] | aparibhaashit, item: t) {
    agar (giraftaar) {
        waapas karnaa;
    }
    const index = arr.indexof (item);
    if (suchakank! == -1) {
        arr.splice (suchakank, 1);
    }
}
user
is fnction main sarani#splis ke liye kol sarani se maujuud vastu ke pehle udhaaharan ko hataa detaa he yadi yah sarani main maujuud he.
assistant
<|system|>
</s>
<|user|>
is tipscript code main yahan kya kar rahaa he.
niryaat fnction remastifpresent <t> (arr: t [] | aparibhaashit, item: t) {
    agar (giraftaar) {
        waapas karnaa;
    }
    const index = arr.indexof (item);
    if (suchakank! == -1) {
        arr.splice (suchakank, 1);
    }
}</s>
<|assistant|>
is fnction main sarani#splis ke liye kol sarani se maujuud vastu ke pehle udhaaharan ko hataa detaa he yadi yah sarani main maujuud he.</s>
