Skip to content

Instantly share code, notes, and snippets.

@cookatrice
Created September 17, 2015 03:28
Show Gist options
  • Save cookatrice/944bfb8c715d642df89c to your computer and use it in GitHub Desktop.
Save cookatrice/944bfb8c715d642df89c to your computer and use it in GitHub Desktop.
toBoolean
function toBoolean(value) {
if (typeof value === 'function') {
value = true;
} else if (value && value.length !== 0) {
var v = lowercase("" + value);
value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
} else {
value = false;
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment