Skip to content

Confusing documentation or bad implementation for util.isObjectΒ #743

Closed
@seishun

Description

@seishun

The documentation for util.isObject states:

Returns true if the given "object" is strictly an Object. false otherwise.

What exactly does "strictly an Object" mean? That the type of the argument is Object? Nope:

> var f = function(){}
undefined
> util.isObject(f)
false

Or maybe it does an instanceof check? That also isn't the case:

> var o = Object.create(null)
undefined
> o instanceof Object
false
> util.isObject(o)
true

Does it check that the [[Class]] internal property is "Object"? Also no:

> Object.prototype.toString.call(JSON)
'[object JSON]'
> util.isObject(JSON)
true

Either the docs should be updated to clarify the behavior, or the implementation should be fixed. I would vote for the latter, otherwise the function name is confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions