if (typeof input !== 'string' || input.length === 0) {
return '';
}
A Curious JavaScripter’s Guide to Monad Pattern
Akash Agrawal
322
The values ‘undefined’, ‘null’, ‘0', NaN and empty string are all falsy values. In other words, you do not need to check both the type and the length. You simply need to coerce the input into a boolean.
More info: https://developer.mozilla.org/en-US/docs/Glossary/Falsy