Cách giải thích Private Constructors & Singletons quá tuyệt (ok)
https://github.com/phamngoctuong/typescript-cheatsheet
class OnlyOne {
private static instance: OnlyOne;
private constructor(public readonly name: string) {}
static getInstance() {
if (!OnlyOne.instance) {
OnlyOne.instance = new OnlyOne('The Only One');
}
return OnlyOne.instance;
}
}
const rightWay = OnlyOne.getInstance();
const anotherWay = OnlyOne.getInstance();PreviousObject for Three Dots, Array for Three Dots (ok)Next[TYPESCRIPT] Một số scripts hay được sử dụng trong typescripts (ok)
Last updated