Question: What is the best way to check if a single character is a whitespace?

I know how to check this through a regex.

But I am not sure if this is the best way if I only have a single character.

Isn't there a better way (concerning performance) for checking if it's a whitespace?

If I do something like this. I would miss white spaces like tabs I guess?

```
if (ch == ' ') {
    ...
}

```

Answer: 
If you only want to test for certain whitespace characters, do so manually, otherwise, use a regular expression, ie

```
/\s/.test(ch)

```

Keep in mind that different browsers match different characters, eg in Firefox, `\s` is equivalent to ([source](https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Regular_Expressions#Using_Special_Characters))

```
[ \f\n\r\t\v\u00A0\u2028\u2029]

```

whereas in Internet Explorer, it should be ([source](http://msdn.microsoft.com/en-us/library/1400241x%28VS.85%29.aspx#sectionToggle2))

```
[ \f\n\r\t\v]

```

The MSDN page actually forgot the space ;)
While it's not entirely correct, I use this pragmatic and fast solution:

```
if (ch.charCodeAt(0) <= 32) {...

```