摘要: 例如,我们要访问 info 对象的 animal 的 reptile 的 tortoise。但是我们不确定 animal,reptile是否存在,因此我们需要这样写: const tortoise = info.animal && info.animal.reptile && info.animal 阅读全文
posted @ 2020-11-25 15:16 酸suan 阅读(133) 评论(0) 推荐(0) 编辑
摘要: let x = (foo !== null && foo !== undefined) ? foo : bar(); 版本二: let x = foo ?? bar(); 阅读全文
posted @ 2020-11-25 14:51 酸suan 阅读(137) 评论(0) 推荐(0) 编辑
摘要: //Number类型在超过9009199254740991后,计算结果即出现问题 const num1 = 90091992547409910; console.log(num1 + 1); //90091992547409900 //BigInt 计算结果争取 const num2 = 90091 阅读全文
posted @ 2020-11-25 14:22 酸suan 阅读(515) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-11-25 14:11 酸suan 阅读(263) 评论(0) 推荐(0) 编辑