Skip to content

Shallow object comparison #2340

@ELLIOTTCABLE

Description

@ELLIOTTCABLE

So, this is precisely the sort of iteration-related, actually-relatively-simple task that I usually rely on Lodash to implement for me; so, in that vein, would the following function, or an approximation thereof, be welcome?

function isShallowEqual(v, o) {
    for(var key in v)
        if(!(key in o) || v[key] !== o[key])
            return false

    for(var key in o)
        if(!(key in v) || v[key] !== o[key])
            return false

    return true }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions