String.isNullOrWhitespace() - mkloubert/jsToolbox GitHub Wiki

String.isNullOrWhitespace(str) method

Checks if a string is NULL, empty or contains whitespaces only.

Syntax

String.isNullOrWhitespace(str);

Result

String is NULL / empty / contains whitespaces only or not.

Examples

// (true)
var res1 = String.isNullOrWhitespace('     ');
// (true)
var res2 = String.isNullOrWhitespace('');
// (false)
var res3 = String.isNullOrWhitespace(' TM ');
// (true)
var res4 = String.isNullOrWhitespace(null);