UNPKG

com-tools

Version:

com-tools 提供了一些通用的工具函数;

102 lines (47 loc) 1.42 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [com-tools](./com-tools.md) &gt; [array\_insertItem](./com-tools.array_insertitem.md) ## array\_insertItem() function insertItem(item, toIndex = 0, equalTest) 将指定元素插入到调用者数组中指定索引处,并且会删除调用者数组中与 item 相同的元素 **Signature:** ```typescript export declare function array_insertItem<T>(array: T[], item: T, toIndex?: number, equalTest?: TestFun<T>): T[]; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> array </td><td> T\[\] </td><td> </td></tr> <tr><td> item </td><td> T </td><td> : any 被插入的元素 </td></tr> <tr><td> toIndex </td><td> number </td><td> _(Optional)_ : number 元素被插入到的位置的索引 </td></tr> <tr><td> equalTest </td><td> [TestFun](./com-tools.testfun.md)<!-- -->&lt;T&gt; </td><td> _(Optional)_ ? : (a,b)=<!-- -->&gt;<!-- -->boolean 可选, 默认是通过全等 === 来判断元素是否相等的;测试数组元素是否相同的函数,返回 boolean 值,表示 元素a 和 元素b 相同; </td></tr> </tbody></table> **Returns:** T\[\] Array<Item> 被删除的元素