每个结构化克隆算法都可以复制`Math`?

时间:2017-01-20 07:47:15

标签: javascript google-chrome indexeddb

以下内容不会在Chrome中引发DataCloneError DOMException

self.postMessage(Math, '*');

这是structured cloning algorithm的预期行为吗?

它在IndexedDB test中使用(当前缺少失败导致测试将Math视为可克隆(尽管无效)密钥路径密钥)所以我很好奇...

1 个答案:

答案 0 :(得分:2)

Object.getOwnPropertyDescriptor(Math, 'abs').enumerable 的函数属性不可枚举(请参阅herehere),因此StructuredClone会跳过它们。

Beth

在上面评论的func示例中,const React = require('react-native') const { StyleSheet } = React const underlineColorAndroid = '#F86C51' module.exports = StyleSheet.create({ background: { backgroundColor: '#F5FCFF', }, }) 最终会在原型上结束,因此它不是"自己的属性"因而也被忽略了。

好像是FF中的一个错误。