Avatar ·

TypeScript में extends और implements: क्या अंतर है?

सभी को नमस्ते! मैंने अभी-अभी JavaScript के बाद TypeScript सीखना शुरू किया है और दो key words — `extends` और `implements` में उलझ गया हूँ। दोनों का उपयोग classes और interfaces के साथ काम करने के लिए होता है, लेकिन मुझे समझ नहीं आ रहा कि कब क्या apply करूँ। मेरे पास एक simple interface `Animal` है, जो basic properties और methods को describe करता है: ```typescript interface Animal { name: string; makeSound(): void; } ``` और मैं एक class `Dog` बनाना चाहता हूँ। Examples में मैंने देखा है कि `extends` और `implements` दोनों का उपयोग किया जाता है: ```typescript // Option 1: implements class Dog implements Animal { name: string; constructor(name: string) { this.name = name; } makeSound() { console.log("Woof!"); } } // Option 2: extends (अगर कोई base class हो) class AnimalBase { name: string; constructo