-
-
Save shakahl/7d08e1baaf190597a142702bfc835523 to your computer and use it in GitHub Desktop.
Parse boolean values (accepts any truthy or falsy values)
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 parseBool (value){ | |
var isEmptyString = (typeof value === "string" && value.length <= 0); | |
var isFalsy = typeof value === "undefined" || isEmptyString; | |
return !isFalsy && !!JSON.parse(value); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment