gpt4 book ai didi

arrays - as3数组按索引删除

转载 作者:行者123 更新时间:2023-12-02 01:58:14 24 4
gpt4 key购买 nike

我有一个数组“cat”、“dog”、“budgie”

并且想要通过索引删除该项目。

目前我已经

function removeit(myindex) {
animals[myindex] = animals.pop()
}

最佳答案

你想要拼接

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#splice%28%29

Array.splice(起点,删除计数);

 var newArray:Array = myArray.splice(2, 1); //this removes whatever is at index 2 and returns it in a new array.

将您的功能更改为

function removeit(myindex) {
animals.splice(myindex, 1);
}

关于arrays - as3数组按索引删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10089806/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com