Removing elements from JavaScript arrays

后端 未结 5 2058
别跟我提以往
别跟我提以往 2021-02-10 22:31

I have the following array setup, i,e:

var myArray = new Array();

Using this array, I am creating a breadcrumb menu dynamically as the user add

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-10 22:46

    You do not need to write a function, you can use indexOf() and splice() these two functions.

    You can remove any positional element a element. For example: var name = ['james' , 'tommy' , 'Jimmy' , 'Holon']; var name = name.splice(name.indexOf('Jimmy') , 1);

提交回复
热议问题