-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Adding a method named 'inspect' to an object does not work as expected #1798
Comments
It's documented here. You are free to add an inspect method to your objects, it's only when passing it to If you think the documentation could be better, can you file a pull request with suggestions? |
I think the confusion is that if you type that code into the REPL you get those results which contravenes what you'd expect in any other JS REPL. Ideally the node REPL would function similarly to other JS REPL consoles (principal of least surprise is always nice), but given that is probably not going to occur, ideally:
Working on a documentation PR right now. |
@toddself did you run into anything tricky while trying to document it? |
It's been a few months since the last activity on this issue — closing it for now. Although this issue is closed, a PR clarifying the docs would still be welcome! |
See: nodejs#1798 When an Object is printed in REPL, the actual representation can be overriden by defining `inspect` method on the objects. This patch includes a note about the same in the REPL documentation
See: #1798 When an Object is printed in REPL, the actual representation can be overriden by defining `inspect` method on the objects. This patch includes a note about the same in the REPL documentation. PR-URL: #2142 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
I understand this has probably been like this for a while but I've never created a method named
inspect
on an object. Just spent over two hours trying to debug this.At the very least this should be very well documented. Right now the first link in Google for
node inspect reserved
is a stackoverflow answer and there is no mention of this behavior in the documentation.Obviously running this code in Chrome, Firefox, Safari, etc works as expected.
The text was updated successfully, but these errors were encountered: