Closed
Description
- Version: v5.5.0
- Platform: Linux nicknout 3.2.0-25-generic-pae Working with nvm, nvmw and similar installation managers #40-Ubuntu SMP Wed May 23 22:11:24 UTC 2012 i686 i686 i386 GNU/Linux
- Subsystem: probably V8 (Chrome 44.0.2403.155 behaves similarly)
MWE:
nickolaus@nicknout:~/git/fraction.js$ js
> var obj = {};
undefined
> obj.a = obj.b = function(){throw err};
[Function]
> obj.b();
ReferenceError: err is not defined
at Object.obj.a.obj.b (repl:1:34)
at repl:1:5
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
> obj.a();
ReferenceError: err is not defined
at Object.obj.a.obj.b (repl:1:34)
at repl:1:5
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
>
The strangeness is at Object.obj.a.obj.b (repl:1:34)
Pure MWE JS:
var obj = {};
obj.a = obj.b = function(){throw err};
obj.b();
Is it an error?
If the same object is declared in another way, everything is OK:
> var obj = {};
undefined
> obj.b = function(){throw err};
[Function]
> obj.a = obj.b;
[Function]
> obj.a();
ReferenceError: err is not defined
at Object.obj.b (repl:1:26)
at repl:1:5
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
> obj.b();
ReferenceError: err is not defined
at Object.obj.b (repl:1:26)
at repl:1:5
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
>