Created
September 17, 2015 03:28
-
-
Save cookatrice/944bfb8c715d642df89c to your computer and use it in GitHub Desktop.
toBoolean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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