Zlog
首页时间轴关于
Zlog

一个探索技术、编程和构建 Web 的个人空间。

© 2026 Zlog

导航

首页时间轴关于

链接

首页/类

类

类

Z

Zephyr110

2021年5月2日·1 分钟
|
frontendfrontend-typescript
ts
class Person {
  name: string
  constructor(name: string) {
    this.name = name
  }
  sayHi() {
    return `Hi, my name is ${this.name}`
  }
}
 
var Jothy = new Person('Jothy')
console.log(Jothy.sayHi())

编译后

js
'use strict'
var Person = /** @class */ (function() {
  function Person(name) {
    this.name = name
  }
  Person.prototype.sayHi = function() {
    return 'Hi, my name is ' + this.name
  }
  return Person
})()
var Jothy = new Person('Jothy')
console.log(Jothy.sayHi())

标签

frontendfrontend-typescript

评论

相关文章

Facade

外观模式:就是提供一个统一的接口去访问多个子系统的多个不同的接口,为子系统中的一组接口提供统一的高层接口。使得子系统更容易使用,不仅简化类中的接口,而且实现调用者和接口的解耦。

2021年12月26日·2 分钟

Singleton

单例模式:就是在整个运行时域,一个类只有一个实例对象。

2021年12月26日·2 分钟

Function Overloading

函数名相同,函数的参数列表不同(参数个数、参数类型),根据参数的不同之行不同的操作。

2021年12月19日·2 分钟

← 返回文章列表