123456789101112131415161718192021222324252627282930 |
- (() => {
- //定义一个接口
- interface iPerson {
- firstName: string
- lastName: string
- }
- //定义一个类
- class Person {
- //定义公共的字段属性
- firstName: string
- lastName: string
- fullName: string
- //定义一个构造函数
- constructor(firstName: string, lastName: string) {
- this.firstName = firstName
- this.lastName = lastName
- this.fullName = this.firstName + this.lastName
- }
- }
- //定义一个函数
- function showFullName(person: iPerson) {
- return person.firstName + '_' + person.lastName
- }
- //实例化对象
- const person = new Person('山东', '蓝翔')
- console.log(showFullName(person))
- })()
|