Skip to content
Browse files

Use __proto__ on the object in the REPL tab-completion.

Some people use __proto__ to augment an Object's prototype after it's been created.
This patch helps make the "new" prototype properties visible if necessary.
  • Loading branch information...
1 parent cf2e68d commit 8bf25e78e95f0784a0a889612ee9477340b30b3d @TooTallNate committed Aug 22, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/repl.js
2 lib/repl.js
@@ -412,7 +412,7 @@ REPLServer.prototype.complete = function(line) {
// works for non-objects
- var p = obj.constructor ? obj.constructor.prototype : null;
+ var p = obj.__proto__;
koichik added a note Aug 23, 2011

__proto__ is not a part of ECMA262, I think that Object.getPrototypeOf() is better:

var p = Object.getPrototypeOf(obj);
TooTallNate added a note Aug 23, 2011

I don't disagree, in fact that was my initial instinct. I wen't with __proto__ because of the comment above this line "works for non-objects". Object.getPrototypeOf() throws on non-objects so I figured that's why that was there.

Though, I couldn't seem to get any tab-completion working on literals anyways, so making it "work for non-objects" might be pointless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
try {
var sentinel = 5;
while (p !== null) {

0 comments on commit 8bf25e7

Please sign in to comment.
Something went wrong with that request. Please try again.