Skip to content

Instantly share code, notes, and snippets.

@renaco
Created June 29, 2017 02:37
Show Gist options
  • Save renaco/ea1826c356b3421c404ffb1ec4584a7a to your computer and use it in GitHub Desktop.
Save renaco/ea1826c356b3421c404ffb1ec4584a7a to your computer and use it in GitHub Desktop.
var fullName = 'Sergio Brito';
console.log(fullName);
function setName(name: string): void {
this.fullName = name;
}
setName('Chicharito');
console.log(fullName);
class Person {
// Properties
name: string;
lastName: string;
age: string;
futureAge: number;
// Methods
greet() {
console.log('Hola ', + this.name);
}
ageFuture() {
console.log('')
}
constructor(name: string, age: number) {
this.name;
this.age;
}
}
var person: Person = new Person('renaco', 36);
person.name = 'renaco';
// person.greet();
class Report {
data: string[];
constructor(data: string[]) {
this.data = data;
}
runs(){
this.data.forEach(function(line){
console.log(line);
})
}
}
var report: Report = new Report([
'Primera línea',
'Segunda línea',
'Tercer línea'
])
report.runs();
class TabbedReport extends Report{
headers: string[];
constructor(headers: string[], values: string[]){
super(values)
this.headers = headers;
}
run() {
console.log(this.headers);
super.runs();
}
}
var headers: string[] = ['Nombre'];
var data: string[] = ['Hugo', 'Paco', 'Luis'];
var tabbedReport: TabbedReport = new TabbedReport(headers, data);
tabbedReport.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment