🧩 一分钟挑战11.08
JavaScript:解构默认值
运行环境:JavaScript。先猜结果,再展开答案。
const { x = 1, y = 2 } = { x: null };
console.log(x, y);
我想好了,查看答案
null 2
解构默认值只在值为 undefined 时生效,不会替换 null。
运行环境:JavaScript。先猜结果,再展开答案。
const { x = 1, y = 2 } = { x: null };
console.log(x, y);
null 2
解构默认值只在值为 undefined 时生效,不会替换 null。
收藏保存在当前浏览器。资源条款与版本兼容性以来源说明为准。
继续拆开今日补给 →