closures - JScript.NET private variables -


I'm thinking about the JScript.NET private variable, please take a look at the following code:

  import system; Import the system. Import system Drawing; Var JSPDF = Function () {var State = 0; Var startpage = function () {state = 2; Outside ('beginPage'); } Var out = function (text) {if (state == 2) {var st = 3; } MessageBox.Show (text + '' + state); } Var addHeader = function () {out ('header'); } Return {endDocument: function () {state = 1; AddHeader (); Outside ('enddocument'); }, Start document: function () {beginPage (); }}} Var j = new JSPDF (); J.beginDocument (); J.endDocument ();  

Output:

  Start Page 2 Header 2 and Document 2  

If I have the same in any browser Run script, output is:

  Start Page 2 Header 1 and Document 1  

Why is it ??

Thank you, Paul.

Just an estimate, but it appears that JScript.NET does not support closing the same way EMCAScript, therefore external documents The state variable is not referring to the private member of the external function, rather a local variable (undeclared). strange.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -