Ramda reject

Ramda reject is opposite to filter.


var data = [

 {fname: 'Roy', lname: 'Red'},

 {fname: 'Gary', lname: 'Green'},

 {fname: 'Bob', lname: 'Blue'},

 {fname: 'Roy', lname: 'Rudy', alt: 'Alt'},

];



var dataUpd = R.pipe(

  R.reject(R.propEq('fname', 'Roy')),

)(data);



alert( JSON.stringify(dataUpd) );

Result:

How to remove object from array


var data = [

 {fname: 'Roy', lname: 'Red'},

 {fname: 'Gary', lname: 'Green'},

 {fname: 'Bob', lname: 'Blue'},

 {fname: 'Roy', lname: 'Rudy', alt: 'Alt'},

];



var itemToCheck = {fname: 'Gary', lname: 'Green'};



var dataUpd = R.reject(R.equals(itemToCheck))(data);

 

alert( JSON.stringify(dataUpd) );

Leave a Comment