5.11. Clone a value

To make a clone of value in targetRealm during transaction, run these steps:

  1. Assert: transaction’s state is active.

  2. Set transaction’s state to inactive.

    The transaction is made inactive so that getters or other side effects triggered by the cloning operation are unable to make additional requests against the transaction.

  3. Let serialized be ? StructuredSerializeForStorage(value).

  4. Let clone be ? StructuredDeserialize(serialized, targetRealm).

  5. Set transaction’s state to active.

  6. Return clone.