الفئات Development Tutorials, Guides & Insights
Unlock 1+ expert-curated الفئات tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your الفئات skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Tutorial
javascript
البرمجة الكائنية (OOP) في JavaScript: المفاهيم الأساسية والتطبيقات
class Animal {
constructor(name) {
this.name = name;
}
speak() {
console.log(`${this.name} يصدر صوتًا.`);
}
}
class Dog extends Animal {
speak() {
console.log(`${this.name} ينبح!`);
}
}
const myDog = new Dog("بلاك");
myDog.speak(); // بلاك ينبح!تعدد الأشكال يعني أن الكائنات يمكن أن تستجيب بطرق مختلفة بناءً على السياق. في المثال السابق، speak() تم تعريفها بشكل مختلف في فئة Dog، على الرغم من أنها ورثت من الفئة Animal.
Sep 26, 2024
Read More