var alldesignationsarr = ['Employee','Manager'];
            Asked
            
        
        
            Active
            
        
            Viewed 68 times
        
    -2
            
            
        - 
                    1[`Array.filter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) – Satpal Jun 19 '18 at 10:59
- 
                    Some example please – Pawan Jun 19 '18 at 10:59
- 
                    1There is no JSON in your question. JSON is a *textual notation* for data exchange. [(More here.)](http://stackoverflow.com/a/2904181/157247) If you're dealing with JavaScript source code, and not dealing with a *string*, you're not dealing with JSON. Your question is simply about removing an object (not a "JSON object') from an array (not a "JSON array"). – T.J. Crowder Jun 19 '18 at 11:01
- 
                    1This is **extremely** well-covered by previous questions and their answers. Please [**search**](/search?q=%5Bjs%5D+filter+array+object) before posting. More about searching [here](/help/searching). – T.J. Crowder Jun 19 '18 at 11:02
1 Answers
0
            
            
        You can use desgdescarr.filter():
var alldesignationsarr = ['Employee','Manager'];
var desgdescarr = [{
    "designation": {
        "name": "Employee",
        "ptest": {}
    },
    
    "designation": {
        "name": "Manager",
        "ptest": {}
    },
    "designation": {
        "name": "Managers",
        "ptest": {}
    }
}];
    
var res = desgdescarr.filter((obj) => alldesignationsarr.indexOf(obj.designation.name) === -1);
console.log(res);If you want to make changes to the original array then you can also use a simple forEach logic for that:
var alldesignationsarr = ['Employee','Manager'];
var desgdescarr = [{
    "designation": {
        "name": "Employee",
        "ptest": {}
    },
    
    "designation": {
        "name": "Manager",
        "ptest": {}
    },
    "designation": {
        "name": "Managers",
        "ptest": {}
    }
}];
    
desgdescarr.forEach((obj, index) => {
  if(alldesignationsarr.indexOf(obj.designation.name) !== -1){
    desgdescarr.splice(index,1);
  }
});
console.log(desgdescarr); 
    
    
        Ankit Agarwal
        
- 30,378
- 5
- 37
- 62
