Q:

Remove Items from array based on Key

I have MAinArray
MainArray=[{
{First Name: "First Name"},
{Last Name: "Contact"},
{Last Name: "Contact"}
]

I want to remove key ,value pair from this array such as
if (key == 'First Name')
{
delete MainArray[key] /// this doesnt work
}

the final result must be
ResultArray=[{
    {Last Name: "Contact"},
    {Last Name: "Contact"}
    ]

A:

You can make use of filter and inside that takes Object.keys of that current Object and check if it includes the given filter:

var MainArray=[ {'First Name': "First Name"}, {'Last Name': "Contact"}, {'Last Name': "Contact"} ];

var result = MainArray.filter(item=>!Object.keys(item).includes('First Name'));

var result2 = MainArray.filter(item=>!item['First Name']);

console.log(result);
console.log(result2);

