Skip to content

console: console.table doesn't fall back to just logging when given a function #20679

Description

@ohbarye
  • Version: v10.1.0
  • Platform: macOS X
  • Subsystem: console

This is a question. (And I admit it's a kind of nitpicking).

Current Behavior

According to the console.table document, it reads that it "falls back to just logging the argument if it can’t be parsed as tabular."

But it doesn't fall back when I give a function as its first argument. It logs an empty table.

$ node

> const f = function() {}
> console.table(f)
┌─────────┐
 (index) 
├─────────┤
└─────────┘
$ node

> class Test {}
> console.table(Test)
┌─────────┐
 (index) 
├─────────┤
└─────────┘

I guess that's because the following line allows a function to proceed the consequent steps.

(typeof tabularData !== 'object' && typeof tabularData !== 'function'))

Question

Is this intentional behavior?

If it's better to change this behavior, I would be glad to send a patch for that.

Activity

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

    consoleIssues and PRs related to the console subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions