Permalink
Browse files

this 在 arrow function

  • Loading branch information...
1 parent 64810f8 commit 9a3d5b83757e5a192a9bb3511f14dce798109a96 Sam.IO.Hsiao committed Nov 5, 2016
Showing with 26 additions and 0 deletions.
  1. +14 −0 this_arrow_function.js
  2. +1 −0 this_arrow_function.js.map
  3. +11 −0 this_arrow_function.ts
@@ -0,0 +1,14 @@
+var MyModule;
+(function (MyModule) {
+ function Foo(name) {
+ var _this = this;
+ 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_arrow_function.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"this_arrow_function.js","sourceRoot":"","sources":["this_arrow_function.ts"],"names":[],"mappings":"AAAA,IAAO,QAAQ,CAOd;AAPD,WAAO,QAAQ,EAAC,CAAC;IACb,aAAoB,IAAY;QAAhC,iBAKC;QAJG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG;YACP,OAAO,CAAC,GAAG,CAAC,YAAU,KAAI,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 = () => {
+ console.log(`Hello, ${this.name}`);
+ }
+ }
+}
+
+var foo = new MyModule.Foo('Sam');
+setTimeout(foo.say, 1000);

0 comments on commit 9a3d5b8

Please sign in to comment.