Skip to content

Instantly share code, notes, and snippets.

@lonekorean
Last active January 2, 2016 08:49
Show Gist options
  • Select an option

  • Save lonekorean/8278639 to your computer and use it in GitHub Desktop.

Select an option

Save lonekorean/8278639 to your computer and use it in GitHub Desktop.
Concise string checking
// assuming str is used to hold a string
if (str !== undefined && str !== null && str.length > 0) {
console.log('str is a non-empty string');
}
if (str) {
console.log('str is a non-empty string');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment