I have an object that I have converted to an array using this
convertToArray(data: any) {
let arr = [];
Object.keys(data).map(function(key){
arr.push(data[key]);
});
return arr;
}
Here is the result
{0: {…}, 1: {…}, 2: {…}, hideTitle: false, template: "football-news", customProperties: {…}}
0: {NewsID: 90, AnotherAttribute: 5, …}
1: {NewsID: 90, AnotherAttribute: 5, …}
2: {NewsID: 90, AnotherAttribute: 5, …}
customProperties: {template: "list-view"}
hideTitle: false
template: "news"
__proto__: Object
to
(6) [{…}, {…}, {…}, false, "football-news", {…}]
0: {NewsID: 90, AnotherAttribute: 5, …}
1: {NewsID: 90, AnotherAttribute: 5, …}
2: {NewsID: 90, AnotherAttribute: 5, …}
3: false
4: "news"
5: {template: "list-view"}
length: 6
__proto__: Array(0)
I want to remove any items (arr.pop or filter) that DOESNT have a NewsID key.
I appreciate any help in advance :)