joyent/node — pull request #2711 by visionmedia (2012-02-08 00:06:44+00:00)
Title: Added support for `.inspect()` to return other objects

for example:

```js

function User(first, last) {
this.first = first;
this.last = last;
this._id = 12345;
this._role = 'admin';
this.inspect = function(){
return {
first: first,
last: last
};
};
}

function UserCollection() {
var users = [];
this.push = function(user){ users.push(user); };
this.inspect = function(){ return users; };
}

var users = new UserCollection;
users.push(new User('tobi', 'ferret'));
users.push(new User('loki', 'ferret'));
users.push(new User('jane', 'ferret'));

console.log(users);
```

will output:

```js
[ { first: 'tobi', last: 'ferret' },
{ first: 'loki', last: 'ferret' },
{ first: 'jane', last: 'ferret' } ]
```

I had added the constructor name like `[User { first: 'tobi' }]` etc but with `[` all over the place it gets really difficult to read although I think that would be useful in general