الوراثة 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: المفاهيم الأساسية والتطبيقات
التغليف هو عملية إخفاء تفاصيل التنفيذ الداخلية للكائن عن العالم الخارجي. يمكن تحقيق ذلك في JavaScript باستخدام الفئات والفئات الخاصة (private classes).
class BankAccount {
constructor(owner, balance) {
this.owner = owner;
this._balance = balance; // خاص
}
deposit(amount) {
if (amount > 0) {
this._balance += amount;
console.log(`تم إضافة ${amount} إلى الحساب.`);
}
}
getBalance() {
return this._balance;
}
}
const account = new BankAccount("علي", 1000);
account.deposit(500);
console.log(account.getBalance()); // 1500Sep 26, 2024
Read More