Remove element from array, using slice

前端 未结 7 1429
野性不改
野性不改 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:44

    Look at here : http://www.w3schools.com/jsref/jsref_slice_array.asp

    You can see that the slice method select object et throw them into a new array object ^^ So you can't delete an object like this, may be you can try a thing like this :

    var a = ["a","b","c"]; (pseudo code)
    /* I wan't to remove the "b" object */
    
    var result = a.slice(0,1)+a.slice(2,1); /* If you considers that "+" is a concatenation operator, i don't remember if it is true... */
    

提交回复
热议问题