Remove element from array, using slice

前端 未结 7 1543
野性不改
野性不改 2021-01-04 02:26

I am trying to remove a element from my array using slice, but i can\'t get it to work, look at this piece of code.

    console.log(this.activeEffects); // P         


        
7条回答
  •  旧巷少年郎
    2021-01-04 02:54

    I believe you're looking for splice. From W3 Schools:

    The splice() method adds/removes items to/from an array, and returns the removed item(s).

    Take a look at the example on that page; the use case there is similar to what you want to achieve.

    EDIT: Alternative link to MDN, as suggested by Nicosunshine; much more information about the command there.

提交回复
热议问题