Skip to main content

Try it Live

Run EventLog examples in the interactive playground

    Clone Behavior

    clone() creates deep copies of mutable fields:
    • Topics array - New array with same topic references
    • Data - New Uint8Array with copied bytes
    • Immutable fields - Shared references (address, hashes, numbers)

    Usage Patterns

    Cloning for Modification

    Cloning Collection

    Preventing Mutation

    Performance

    Clone creates new arrays and copies bytes:
    • Topics array allocation - Small overhead (typically 1-4 elements)
    • Data copy - Proportional to data size (typically 0-1024 bytes)
    • Immutable fields - Zero overhead (shared references)
    For read-only operations, cloning is unnecessary. Only clone when modifications are needed.

    See Also