I need to verify if the object below contains the property forums
and if its value is set to true
.
{forums: true, pages: true, photos: true, videos: true}
Currently, I am working with TypeScript Angular 5.
The code snippet below accomplishes this task effectively.
let item = 'forums';
if (this.itemsmodel.hasOwnProperty(item)) {
//This condition evaluates to true.
if (this.itemsmodel[item]) {
item = item;
} else {
item = 'pages';
}
}
Is there a more Angular or TypeScript-specific approach for achieving this?