Permalink
Browse files

this 在 anonymous function

  • Loading branch information...
0 parents commit 64810f888b29993c148eb73acfb3f888549262e4 Sam.IO.Hsiao committed Nov 5, 2016
Showing with 25 additions and 0 deletions.
  1. +13 −0 this_anonymous_function.js
  2. +1 −0 this_anonymous_function.js.map
  3. +11 −0 this_anonymous_function.ts
@@ -0,0 +1,13 @@
+var MyModule;
+(function (MyModule) {
+ function Foo(name) {
+ this.name = name;
+ this.say = function () {
+ console.log("Hello, " + this.name);
+ };
+ }
+ MyModule.Foo = Foo;
+})(MyModule || (MyModule = {}));
+var foo = new MyModule.Foo('Sam');
+setTimeout(foo.say, 1000);
+//# sourceMappingURL=this_anonymous_function.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"this_anonymous_function.js","sourceRoot":"","sources":["this_anonymous_function.ts"],"names":[],"mappings":"AAAA,IAAO,QAAQ,CAOd;AAPD,WAAO,QAAQ,EAAC,CAAC;IACb,aAAoB,IAAY;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG;YACP,OAAO,CAAC,GAAG,CAAC,YAAU,IAAI,CAAC,IAAM,CAAC,CAAC;QACvC,CAAC,CAAA;IACL,CAAC;IALe,YAAG,MAKlB,CAAA;AACL,CAAC,EAPM,QAAQ,KAAR,QAAQ,QAOd;AAED,IAAI,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,11 @@
+module MyModule {
+ export function Foo(name: string) {
+ this.name = name;
+ this.say = function () {
+ console.log(`Hello, ${this.name}`);
+ }
+ }
+}
+
+var foo = new MyModule.Foo('Sam');
+setTimeout(foo.say, 1000);

0 comments on commit 64810f8

Please sign in to comment.