How to check for an empty string in JavaScript?

To check for an empty string in JavaScript, do this: string === ''.

Here's how you do it:

const emptyString = '';
const notEmptyString = 'Hello World!';

if (emptyString === '') {
  // code inside this "if" runs…
}

if (notEmptyString === '') {
  // code inside this "if" does not run…
}