Skip to content

Cloning Object.create(null) object #588

Closed
@tgriesser

Description

@tgriesser

Not sure what the desired behavior is here, but I assumed that calling _.clone on an object created with Object.create(null) would create a new object which does not inherit from Object.prototype.

var obj = Object.create(null);
// typeof obj.hasOwnProperty === "undefined"
var obj2 = _.clone(obj);
// typeof obj2.hasOwnProperty === "function"

Couldn't find any prior tickets, but I could have missed something.

Activity

jdalton

jdalton commented on Jun 14, 2014

@jdalton
Member

A shallow clone won't do that as it's just _.assign({}, object) and a deep clone is loosely based on the structured cloning algorithm and doesn't attempt to clone inheritance or lack thereof .

lock

lock commented on Jan 21, 2019

@lock

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

locked as resolved and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jdalton@tgriesser

        Issue actions

          Cloning Object.create(null) object · Issue #588 · lodash/lodash