-
-
Save UlyssesWu/ca3a314e660446d15153cfa4aa0fe24d to your computer and use it in GitHub Desktop.
TJS2 examples. Just a reminder. docs: http://devdoc.kikyou.info/tvp/docs/tjs2doc/contents/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
var val; | |
property p { | |
getter { | |
return val; | |
} | |
setter(v) { | |
this.val = v; | |
} | |
} | |
function finalize() { | |
System.inform("finalize(): " + this); | |
} | |
} | |
var foo = new Foo(); | |
foo.p = 123; | |
System.inform(foo); | |
System.inform(typeof foo); | |
System.inform(foo.p); | |
// var foo.bar = 'quux'; // can't do this | |
foo.bar = 'quux'; // can dynamically add members | |
System.inform(foo.bar); | |
(function () { | |
System.inform(this.bar); | |
} incontextof foo)(); | |
delete foo.bar; // can dynamically remove members | |
// (function () { | |
// System.inform(this.bar); | |
// } incontextof foo)(); // member not found, exception | |
invalidate foo; // deterministically destroy object (like C++'s delete operator) | |
System.inform(isvalid foo); //=> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment