isSpace() (Simulated functionality)

Check if a character is whitespace.

Property/method value type:Boolean primitive

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:

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.

Example code:

   // 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