Within my TypeScript module, I have the following code snippet:
import app = require("durandal/app");
import ko = require("knockout");
class Screen1 {
method1(arg: string): string {
return "Hello";
}
method2 = (arg: string): string => {
return "Hello";
};
}
export = Screen1;
This TypeScript code compiles into the JavaScript below:
define(["require", "exports"], function (require, exports) {
"use strict";
var Screen1 = (function () {
function Screen1() {
this.method2 = function (arg) {
return "Hello";
};
}
Screen1.prototype.method1 = function (arg) {
return "Hello";
};
return Screen1;
}());
return Screen1;
});
I can observe the differences in the output for each method, but what practical impact does it have at runtime? My suspicion is that it may alter the context of `this` within those methods, but I am uncertain about how to thoroughly investigate this.
(One aspect of TypeScript that often perplexes me is the array of options available to accomplish seemingly identical tasks, leading to subtle distinctions - such as defining a class. I find it quite confusing and overwhelming)