Skip to content

Instantly share code, notes, and snippets.

@hallojoe
Created February 24, 2019 10:07
Show Gist options
  • Save hallojoe/4877098269c594a8b5dd0c46c9e85f7c to your computer and use it in GitHub Desktop.
Save hallojoe/4877098269c594a8b5dd0c46c9e85f7c to your computer and use it in GitHub Desktop.
A thing JavaScript that convert a boolean'ish strings and a number to boolean
var isTrue = function (value) {
if ('string' === typeof (value)) value = value.toLowerCase().trim();
return ['true', '1', 'on', 'yes', 1].indexOf(value) > -1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment