js
structuredClone(value)النسخة مستقلة تمامًا: التعديل فيها مابيأثرش في الأصل ولا العكس. بتتعامل مع المراجع الدائرية من غير error. مابتنسخش الدوال ولا عناصر الـDOM — بترمي DataCloneError.
البرهان
js
const order = { id: 1, items: [{ name: 'كتاب', qty: 2 }], at: new Date(0) };
const copy = structuredClone(order);
copy.items[0].qty = 5;
console.log(order.items[0].qty, copy.items[0].qty);
console.log(copy.at instanceof Date, copy.items !== order.items);
const c = {};
c.me = c;
const cc = structuredClone(c);
console.log(cc.me === cc, cc !== c);
try {
structuredClone(() => 1);
} catch (e) {
console.log(e.constructor.name);
}النتيجة
2 5 true true true true DOMException