【发布时间】:2017-03-10 08:02:10
【问题描述】:
function test(o) {
console.log("Object:", o);
console.log("Assign test:", Object.assign({}, o));
console.log("Keys test:", Object.keys(o));
console.log("JSON test:", JSON.stringify(o));
}
var el = document.getElementById("question"); /* or document.body */
test(el.style); /* works as expected */
test(el.getBoundingClientRect()); /* behaves like {} */
test(Object.assign(el.getBoundingClientRect(),{aaaa: 1111})); /* works... only for aaaa */
为什么?
输出(测试结果)
见PasteBin。
MDN 文档
【问题讨论】:
-
你能在这里添加输出吗?
-
@MertAkcakaya:我正在尝试添加输出,但 StackOverflow 阻止它并显示消息“看起来您的帖子主要是代码;请添加更多细节。” ☹ 所以我把它贴在了 PasteBin 上。
标签: javascript getboundingclientrect