Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert string, number to boolean value
function cleanBooleanParam(value) {
switch(value.toString().toLowerCase()) {
case "true":
case "on":
case "yes":
case "1":
return true;
case "false":
case "off":
case "no":
case "0":
return false;
return value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment