Remove object in array using filter and splice which one is best approach in JavaScript?

前端 未结 5 1568
抹茶落季
抹茶落季 2020-12-31 09:18

Hi I delete an object in an array using two approaches:- splice and filter.

splice code here:-

(this.myArray).splice((this.myArray).indexOf(myobjec         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 09:51

    In case you know the index using splice would be an O(1) operation while using filter is an O(n) operation.

提交回复
热议问题