How to simplify simple statement in typescript or js

I would like to simplify this expression but don’t know how. There has to be a way to have the same expression without the three conditions.

if ( request.Document != null &&
      request.Document != undefined &&
      request.Document != "" )

Just for context I am talking something similar to c#’s !string.isNullOrEmpty()

>Solution :

if (request.Document) {

as null, undefined, '' will all return false.

(but [], {} or ' ' will return true)

Check the equality table for more info about other values.

Leave a Reply