DEV Community

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

Collapse
 
kpruehss profile image
Karsten Pruehss

Checking the array length in the if condition could be shortened to just !blogPost.length which will evaluate to true if the array is empty since 0 is falsy and gets inverted and coerced into a boolean.

Collapse
 
ondrabus profile image
Ondrej Polesny

True, thanks for the comment! :-)