Skip to content

I have a question about the isPlainObject method. #102

@ajiho

Description

@ajiho

In lodash, the following three cases all return true,

_.isPlainObject({ x: 0, y: 0 }) // true
_.isPlainObject(Object.create(null))  //true
_.isPlainObject(new Object()) //true

but in is-what it’s different.

d.isPlainObject({ x: 0, y: 0 }) //true
d.isPlainObject(Object.create(null)) //false
d.isPlainObject(new Object()) // true

So, is this difference intentional by design, or is it a bug?

Here are some new findings: jQuery and Lodash behave consistently.

$.isPlainObject({ x: 0, y: 0 }) // true
$.isPlainObject(Object.create(null)) //true
$.isPlainObject(new Object()) //true

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