PS-121.322: (Javascript) Code outlining question

Hello, again.

Here is the code:

var Class = (function(){      var _PrivateClass = (function(){
          function _PrivateClass(){}
          _PrivateClass.prototype.someMethod = function(){};           return _PrivateClass;      }());      var _privateVar;      var _functionRef;      var _functionRef2;      function Class(){           _functionRef = function(){};           _functionRef2 = (function(){});      }      return Class; }());



Why in the code structure window both 'classes' (Class (marked as v) and _PrivateClass (marked as C)) are displayed in global scope? Besides _PrivateClass also displayed in scope of Class (marked as v)! And why, when I comment out someMethod prototype, _PrivateClass disappears from global scope? Is there anything wrong with my code?

Same stranginess occurs with function assignment. In above example _functionRef jumps out into global scope after assignment in constructor, while _functionRef2 doesn't - why this happens?

Thanks in advance.

Regards.
Roman

Please sign in to leave a comment.