代码拉取完成,页面将自动刷新
// 使用Boolean函数
// 数字转bool, 除了0和NaN, 其余都为true
const a = '123';
const b = Boolean(a);
console.log('b: ', b, typeof b); // b: true boolean
// 字符串转bool, 除了'', 其余都为true
const c = '';
const d = Boolean(c);
console.log('d: ', d, typeof d); // d: false boolean
// null和undefined转bool, 都为false
const e = null;
const f = Boolean(e);
console.log('f: ', f, typeof f); // f: false boolean
const g = undefined;
const h = Boolean(g);
console.log('h: ', h, typeof h); // h: false boolean
// 对象也会转换为true
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。