“Konwertuj ciąg true na boolean true javascript” Kod odpowiedzi

Ciąg do 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;
    }
}
NotDamian

Konwertuj ciąg true na boolean true javascript

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);
    }
}
Rich Rat

JS String to Boolean

// Do
var isTrueSet = (myValue == 'true');
// Or
var isTrueSet = (myValue === 'true');
Cybernated Dev

Odpowiedzi podobne do “Konwertuj ciąg true na boolean true javascript”

Pytania podobne do “Konwertuj ciąg true na boolean true javascript”

Więcej pokrewnych odpowiedzi na “Konwertuj ciąg true na boolean true javascript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu