Skip to content

Instantly share code, notes, and snippets.

@civic
Last active December 14, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save civic/5097699 to your computer and use it in GitHub Desktop.
Save civic/5097699 to your computer and use it in GitHub Desktop.
var person = require("./Person")
var p = new person.Person('John');
p.show();
console.log("direct access: " + p.name);
import person = module("Person");
var p:person.Person = new person.Person('John');
p.show();
console.log("direct access: " + p.name);
var person = require("./Person_modify")
var p = new person.Person('John');
p.show();
console.log("direct access: " + p.name);
$ node Main.js
John
direct access: John
$ node Main_modify.js
John
direct access: undefined
var Person = (function () {
function Person(n) {
this.name = n;
}
Person.prototype.show = function () {
console.log(this.name);
};
return Person;
})();
exports.Person = Person;
export class Person {
private name:string;
constructor (n:string){
this.name = n;
}
show(){
console.log(this.name);
}
}
var Person = (function () {
var name;
function Person(n) {
name = n;
}
Person.prototype.show = function () {
console.log(name);
};
return Person;
})();
exports.Person = Person;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment