有人可以解释以下Java脚本代码

时间:2018-10-30 07:40:28

标签: javascript typescript

我最近正在阅读打字稿文档

参考: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基础的良好参考。

0 个答案:

没有答案