Skip to content

Instantly share code, notes, and snippets.

@ceving
Created February 11, 2023 11:50
Show Gist options
  • Save ceving/d177bdf93015c8dd4498542f5cce35b3 to your computer and use it in GitHub Desktop.
Save ceving/d177bdf93015c8dd4498542f5cce35b3 to your computer and use it in GitHub Desktop.
JavaScript Limerick: !!(new Boolean(false)) === true
function coerce_boolean_correctly (arg) {
if (arg instanceof Boolean)
return coerce_boolean_correctly(arg.valueOf())
return !!arg
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment