🧩 一分钟挑战11.17
JavaScript:JSON 会保留 undefined 吗?
运行环境:JavaScript。先猜结果,再展开答案。
console.log(JSON.stringify({ a: undefined, b: null }));
我想好了,查看答案
{"b":null}
对象中值为 undefined 的属性会被忽略;数组中的对应行为不同。
运行环境:JavaScript。先猜结果,再展开答案。
console.log(JSON.stringify({ a: undefined, b: null }));
{"b":null}
对象中值为 undefined 的属性会被忽略;数组中的对应行为不同。
收藏保存在当前浏览器。资源条款与版本兼容性以来源说明为准。
继续拆开今日补给 →