I want to test weather array of custom type objects are empty or not . Here '?' is not checking empty and running the code and failing in case empty messageArray.
messageArray?.forEach((message: BannerMessage) => {
const outPutMessageObj: OutPutMessage = this.getOutPutMessageObject(message);
processedMessages.push(outPutMessageObj);
});
The error i am getting is
Uncaught (in promise) TypeError: messageArray.forEach is not a function