Skip to content
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

util: display constructor name when inspecting objects #1935

Closed
wants to merge 2 commits into from
Closed

util: display constructor name when inspecting objects #1935

wants to merge 2 commits into from

Commits on Aug 7, 2015

  1. util: display constructor when inspecting objects

    This commit modifies util.inspect(obj) to additionally show the name of
    the function that constructed the object. This often reveals useful
    information about the object's prototype. In other words, instead of
    
    > new Cls
    {}
    
    we have
    
    > new Cls
    Cls {}
    
    This also works with exotic objects:
    
    > class ArrayCls extends Array {}
    > new ArrayCls(1, 2, 3)
    ArrayCls [ 1, 2, 3 ]
    
    The names of "trivial" constructors like Object and Array are not shown,
    unless there is a mismatch between the object representation and the
    prototype:
    
    > Object.create([])
    Array {}
    
    This feature is inspired by browser devtools.
    monsanto committed Aug 7, 2015
    Configuration menu
    Copy the full SHA
    022c0cd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    38de750 View commit details
    Browse the repository at this point in the history