Skip to content

inline assoc, dissoc, get on objects? #728

Description

@borkdude

We could do this:

{ ...{ x: 1 }, y: 2, z: 3 }

if we knew for sure that the argument map was a JS object.

dissoc:

(({ key1, key2, ...rest }) => rest)(obj)

get with default:

"a" in x ? x["a"] : 42;

Of course you could shrink the size of the above by calling rest some single char thing

(conj ^array x b c) => […x, b, c]

For Map:

const m2 = new Map([...m1, ['x', 10], ['y', 20]]);

Would be worth checking if this is any faster than a function in which we do this only for objects

  • contains? -> "key" in object

  • doto -> comma expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions