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: 
this covers spaces, tabs and newlines:

```
if ((ch == ' ') || (ch == '\t') || (ch == '\n'))

```

this should be best for performance. put the whitespace character you expect to be most likely, first.

if performance is really important, probably best to consider the bigger picture than individual operations like this...
```
function hasWhiteSpace(s) {
  return /\s/g.test(s);
}

```

This will work

or 
you can also use this indexOf():

```
function hasWhiteSpace(s) {
  return s.indexOf(' ') >= 0;
}

```