М
Size: a a a
М
AG
AG
М
PS
interface ICat {
name: string;
new(name: string): ICat
meow(): string;
}
const Cat = (function () {
function Cat(this: ICat, name: string) {
this.name = name;
}
Cat.prototype.meow = function (this: ICat) {
return this.name + ' says: meow!'
};
return Cat as unknown as ICat;
}());
const cat = new Cat('kitty');
console.log(cat.meow());М
AG
interface ICat {
name: string;
new(name: string): ICat
meow(): string;
}
const Cat = (function () {
function Cat(this: ICat, name: string) {
this.name = name;
}
Cat.prototype.meow = function (this: ICat) {
return this.name + ' says: meow!'
};
return Cat as unknown as ICat;
}());
const cat = new Cat('kitty');
console.log(cat.meow());PS
М
PS
PS
AG
PS
interface ICat {
name: string;
meow(): string;
}
function Cat(name: string): ICat {
return Object.freeze({ name, meow });
function meow() {
return name + ' says: meow!'
}
}
const cat = Cat('kitty');
console.log(cat.meow());V
interface ICat {
name: string;
meow(): string;
}
function Cat(name: string): ICat {
return Object.freeze({ name, meow });
function meow() {
return name + ' says: meow!'
}
}
const cat = Cat('kitty');
console.log(cat.meow());М
М
PS
I