我最近正在阅读打字稿文档
参考:http://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
在本文档中,与typescript
部分相关的类似classes
代码如下
class Student {
fullName: string;
constructor(public firstName: string) {
this.fullName = firstName;
}
}
interface Person {
firstName: string;
}
function greeter(person : Person) {
return "Hello, " + person.firstName;
}
let user = new Student("Jane");
document.body.innerHTML = greeter(user);
我用compiled
tsc filename.ts
将此代码
它给了我一个javascript编译后的代码,
var Student = /** @class */ (function () {
function Student(firstName) {
this.firstName = firstName;
this.fullName = firstName;
}
return Student;
}());
function greeter(person) {
return "Hello, " + person.firstName;
}
var user = new Student("Jane");
document.body.innerHTML = greeter(user);
在此生成的javascript代码中,我想了解这一部分:
var Student = /** @class */ (function () {
function Student(firstName) {
this.firstName = firstName;
this.fullName = firstName;
}
return Student;
}());
我希望有人能帮我提供有关Javascript基础的良好参考。