const str1 = 'true';
const str2 = 'false';
const bool1 = JSON.parse(str1.toLowerCase());
const bool2 = JSON.parse(str2.toLowerCase());
console.log(bool1, bool2) // true false
如何将字符串的‘true‘ ‘false‘ 转为布尔值的 true false?
最新推荐文章于 2023-09-13 14:41:46 发布