'How to verify type script array of custom type objects are empty or not?
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
