1. 转换为字符串 ?将一个值加上空字符串可以转换为字符串类型。```‘‘ + 10 === ‘10‘; // true```2. 字符串转换为数字```+‘010.2‘//10.2Number(‘010.2‘)//10.2parseInt(‘010.2‘, 10)//10```3. 转换为布尔值 ?通过使用 否 操作符两次,可以把一个值转换为布尔型。```!!‘foo‘; ?// true!!‘‘; ??// false!!‘0‘; ??// true!!‘1‘; ??// true!!‘-1‘ ??// true!!{}; ??// true!!true; ?// true```
JS-类型转换
原文地址:https://www.cnblogs.com/jffun-blog/p/10206593.html