isStrictEmpty (JavaScript)

Checks whether a string is empty except for spaces.

Defined in

String (Standard - JavaScript)

Syntax

isStrictEmpty() : boolean
Return value Description
boolean True if the string is empty except for spaces; otherwise false.

Usage

An empty string has a length of 0. Spaces add length.

Examples

(1) This example returns the content of cities.
var cities = "Paris";
// Should not be empty
if (cities.isStrictEmpty()) {
	return "Empty";
} else {
	return "'" + cities + "'";
}
(2) This example returns Empty.
var cities = "";
// Should be empty
if (cities.isStrictEmpty()) {
	return "Empty";
} else {
	return "'" + cities + "'";
}
(3) This example returns Empty.
var cities = "   ";
// Should be empty
if (cities.isStrictEmpty()) {
	return "Empty";
} else {
	return "'" + cities + "'";
}