Skip to content

Difference with Object.freeze #4

Open
@alexpods

Description

@alexpods

Can you explain: how new record:

const xy = #{ x: 1, y: 2 }; // frozen value type
const xyz = #{ ...xy, z: 3 }; // functional extension

is different from:

const xy = Object.freeze({ x: 1, y: 2 });
const xyz = Object.freeze({ ...xy, z: 3 });

?

And how new tuple:

const xy = #[ x, y ]; // frozen value type
const xyz = #[ ...xy, z ]; // functional extension

is different from this:

const xy = Object.freeze([ x, y ]); // frozen value type
const xyz = Object.freeze([ ...xy, z ]); // functional extension

?

If they're not deep immutable, it's looks like there are no differences. I suspect new types have some performance gains, but don't understand how it can be achieved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions