Node.js REPL automatically declares underscore after a function declaration or function expression?

I found out something weird about node.js today:

$ node
> console.log(_)
ReferenceError: _ is not defined
    at repl:1:13
    at REPLServer.defaultEval (repl.js:130:27)
    at bound (domain.js:257:14)
    at REPLServer.runBound [as eval] (domain.js:270:12)
    at REPLServer.<anonymous> (repl.js:277:12)
    at REPLServer.EventEmitter.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:202:10)
    at REPLServer.Interface._line (readline.js:531:8)
    at REPLServer.Interface._ttyWrite (readline.js:812:14)
    at ReadStream.onkeypress (readline.js:101:10)
> function foo() {}
undefined
> console.log(_)
undefined
undefined

The same thing happens after I create a function expression:

$ node
> console.log(_)
ReferenceError: _ is not defined
    at repl:1:13
    at REPLServer.defaultEval (repl.js:130:27)
    at bound (domain.js:257:14)
    at REPLServer.runBound [as eval] (domain.js:270:12)
    at REPLServer.<anonymous> (repl.js:277:12)
    at REPLServer.EventEmitter.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:202:10)
    at REPLServer.Interface._line (readline.js:531:8)
    at REPLServer.Interface._ttyWrite (readline.js:812:14)
    at ReadStream.onkeypress (readline.js:101:10)
> (function () {}())
undefined
> console.log(_)
undefined
undefined

It's pretty cool, and handy for function arguments which you intentionally want to leave as undefined, but why does it happen? I am using node version v0.11.13 on Arch Linux.

It's a feature of the repl: _ returns the result of the last expression.

Of course, in some cases - like the console.log you have - an expression will not return a result. But yeah it's a handy way to get the value of the last expression.

This only happens in the REPL of course - if you type up the same node program and run it from a file, _ will be under your control.