js string to boolean

JavaScript
let toBool = string => string === 'true' ? true : false;
// Not everyone gets ES6 so here for the beginners
function toBool(string){
	if(string === 'true'){
      return true;
    } else {
      return false;
    }
}stringToBoolean: function(string){
    switch(string.toLowerCase().trim()){
        case "true": case "yes": case "1": return true;
        case "false": case "no": case "0": case null: return false;
        default: return Boolean(string);
    }
}// Do
var isTrueSet = (myValue == 'true');
// Or
var isTrueSet = (myValue === 'true');var isHidden='true';
var isHiddenBool = (isHidden == 'true');var thing = true; //try changing this to false
thing = !thing; //the variable will go from true to false, or from false to trueconst stringBools = [
  'true',
  'false',
  'asdf'
];
const bools = [];

for (const i = 0; i < stringBools.length; i++) {
  const stringBool = stringBools[i];
  if (stringBool == true) {
    bools.push(true);
  } else if (stringBool == false) {
    bools.push(false);
  } else {
    bools.push(null /* Change if you like */);
  }
}
Source

Also in JavaScript: