📜  5.1.2.布尔转换¶ - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:31.255000             🧑  作者: Mango

代码示例1
/*As with the number and string data types, the boolean type also has 
a conversion function, Boolean. It works similarly to the Number and 
String functions, attempting to convert a non-boolean value to a 
boolean.*/

console.log(Boolean("true"));  //true
console.log(Boolean("TRUE"));  //true
console.log(Boolean(0));  //false
console.log(Boolean(1));  //true
console.log(Boolean(''));  //false
console.log(Boolean('LaunchCode'));  //true