List of utility methods to do String to Boolean Convert
toBool()String.prototype.toBool = function() { return (/^true$/i).test(this); }; | |
toBool()String.prototype.toBool = function() return this.toLowerCase() === 'true'; }; | |
toBool()String.prototype.toBool = function() { switch(this.toLowerCase()) { case 'true': case 'yes': case '1': return true; case 'false': case 'no': case '0': case null: return false; default: return Boolean(this); }; | |
toBoolOrString()String.prototype.toBoolOrString = function () { return this === 'true' ? true : this === 'false' ? false : this.toString(); }; | |
toBoolean()String.prototype.toBoolean = function () { return this == 'true'; }; String.prototype.isBoolean = function () { return this === 'true' || this === 'false'; }; | |
toBoolean()String.prototype.toBoolean = function(){ return Boolean(+this) || this.isYes(); }; | |
toBoolean()String.prototype.toBoolean = function () { return (/^true$/i).test(this); }; | |
toBoolean()String.prototype.toBoolean = function () { if (this.valueOf()) return new RegExp(/^(true)$|^(1)$|^(s){1}$/i).test(this.valueOf()) return false; | |
toBoolean()String.prototype.toBoolean = function () { if (this && this.toLowerCase() === 'true') { return true; else { return false; }; |