Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

delete item from array of objects javascript

var removeByAttr = function(arr, attr, value){
    var i = arr.length;
    while(i--){
       if( arr[i] 
           && arr[i].hasOwnProperty(attr) 
           && (arguments.length > 2 && arr[i][attr] === value ) ){ 

           arr.splice(i,1);

       }
    }
    return arr;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #delete #item #array #objects #javascript
ADD COMMENT
Topic
Name
1+6 =