Archive for the ‘class simulation’ Tag
Note on simulating classes
Thinking of C#…
Instance properties would look something like this:
Class(param) {
this.property = param;
}
Instance methods:
Class.prototype.method = function () { /* function body... */ };
Class properties (similar to “static” in C#):
Class.PROPERTY = value;
Class methods – invoked through the class itself, not any particular instance of the class. The “this” keyword does not refer to any particular instance of the class but tot the constructor function itself. Typically “this” is not used at all. Operations are not on instances but on any passed in parameters or variables in scope.
Class.method = function () { /* function body... */ };
Leave a comment