Skip to content

Cloning Object.create(null) object #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tgriesser opened this issue Jun 14, 2014 · 2 comments
Closed

Cloning Object.create(null) object #588

tgriesser opened this issue Jun 14, 2014 · 2 comments
Labels

Comments

@tgriesser
Copy link

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.

@jdalton
Copy link
Member

jdalton commented Jun 14, 2014

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 .

@jdalton jdalton closed this as completed Jun 14, 2014
@lock
Copy link

lock bot commented Jan 21, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants