Skip to content

Instantly share code, notes, and snippets.

@civic civic/Main.js

Last active Dec 14, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.