Determines whether or not a string is empty or contains only whitespace characters.

Syntax

JSV_isWhitespace(expS)

Prototype

expS.isWhitespace()

Returns

The isWhitespace function returns true if the expression expS is empty or contains only whitespace characters; otherwise, false.

Parameters

The isWhitespace function uses the following argument.

Argument Description
expS The string that is to be evaluated.

Remarks

The whitespace characters are:

Whitespace
Character
  Character
Information
    space
\t   tab
\n   line feed
\r   carriage return

A string is considered empty if its length is 0 or it is null.

Dependencies

JSV_isEmpty

Example

The following lines of code

var testString1 = "   ", testString2 = "Bob\n";
document.write( "testString1 is white space? " +
    JSV_isWhitespace(testString1) );
document.write( "testString2 is white space? " +
    JSV_isWhitespace(testString2) );
var testNumber = 123;
document.write( "testNumber is white space? " +
    JSV_isWhitespace(testNumber) );

produce