This is a function normally found in the C language. However, it is useful to script developers as well and may be available in some implementations as an extension to the ECMA standard functionality.
Any whitespace character should return true for this function. The following character codes are considered to be whitespace:
The space character
A form feed character
A Newline character
A carriage return
A tab character
A vertical tab
Strictly speaking, this function should be coded to be aware of locale specific issues. You may want to take the example simulation provided here and modify it to your own needs to support that. This is just a basic working example.
// Test for space characters
function isSpace(aChar)
{
myCharCode = aChar.charCodeAt(0);
if(((myCharCode > 8) && (myCharCode < 14)) ||
(myCharCode == 32))
{
return true;
}
return false;
}| See also: | Character handling, Character testing, Enquiry functions, Letter |
| Prev | Home | Next |
| isPunct() | Up | isUpper() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. | ||