Open terrymorse58 opened 4 years ago
Also, in the following test, clone failed to copy the ArrayCustom
prototype.
class ArrayCustom extends Array {
custom() { return true; }
}
let src = [1, 2, ArrayCustom.from(["I", "am", "foo"])];
let dest = clone(src);
dest[1] = 2.00001;
console.log(src);
// [ 1, 2, ArrayCustom [ 'I', 'am', 'foo' ] ]
console.log(dest);
// [ 1, 2.00001, [ 'I', 'am', 'foo' ] ]
let destCustom = dest[2];
if (!(destCustom instanceof ArrayCustom)) {
throw "Error: failed to preserve ArrayCustom prototype";
}
// Error: failed to preserve ArrayCustom prototype
The following clone test of an array containing a
WeakMap
produces an error:An identical error occurs when running a similar test with
WeakSet
: