I have inserted objects with a new property(property name - "Type") to a JS array. After that, I need to filter objects with that property(which is "Type") to a new array.
var arr = [
{ID: 1, Name: "Name1"},
{ID: 2, Name: "Name2"}]
var newObject = {
ID: 3,
Name: 'Test',
Type: 'New'
};
arr.push(newObject);
I tried
var newVal = arr.filter(x => x.Type !== null);
it returns all the object from array
result should be
[{ ID: 3, Name: "Test", Type: "New" }]