DEV Community

Discussion on: How To Check If Array Is Empty In TypeScript

Collapse
 
ondrabus profile image
Ondrej Polesny

Actually, it is. The API response is typed, so in case you get different type of data, it won't get mapped to the type and the items array will be empty which in the end helps you handle the problem.
However, the Array.isArray will work in pure JS too.