Remove Object from Array using JavaScript

前端 未结 29 2589
南笙
南笙 2020-11-22 10:24

How can I remove an object from an array? I wish to remove the object that includes name Kristian from someArray. For example:

som         


        
29条回答
  •  失恋的感觉
    2020-11-22 10:51

    You could also try doing something like this:

    var myArray = [{'name': 'test'}, {'name':'test2'}];
    var myObject = {'name': 'test'};
    myArray.splice(myArray.indexOf(myObject),1);
    

提交回复
热议问题