/ Published in: JavaScript
Expand |
Embed | Plain Text
Book = (function(v1) { var _v1 = v1; return function(v2) { if (v2) { return v2; } else { return (_v1) ? { pub_v: _v1.replace(/_v1/, 'pub_v'), getTitle: function() { return "Got private through public getter: " + _v1; }, getMe: function() { return this; } } : "Nuthin'!" } }; })('Ethics1 (_v1 as v1)'); console.log( Book('Ethics2 (return v2)') + " & " + Book().getTitle() + " & static public: " + Book().pub_v + " & " + Book().getMe()); //o: Ethics2 (return v2) & Got private through public getter: Ethics1 (_v1 as v1) & static public: Ethics1 (pub_v as v1) & [object Object] Book().getMe(); //o: [object Object] as { pub_v: .... }
You need to login to post a comment.
