DeveloperBreeze

التغليف 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.

Tutorial
javascript

البرمجة الكائنية (OOP) في JavaScript: المفاهيم الأساسية والتطبيقات

الفئات هي القوالب التي نستخدمها لإنشاء الكائنات. في السابق، كانت JavaScript تعتمد على النماذج (prototypes) لإنشاء الكائنات، لكن منذ ES6، أصبحت الفئات (classes) جزءًا من اللغة.

class Car {
    constructor(brand, model, year) {
        this.brand = brand;
        this.model = model;
        this.year = year;
    }

    startEngine() {
        console.log(`${this.brand} ${this.model} قد بدأ تشغيل المحرك!`);
    }

    stopEngine() {
        console.log(`${this.brand} ${this.model} قد أوقف تشغيل المحرك.`);
    }
}

const myCar = new Car("Toyota", "Corolla", 2020);
myCar.startEngine();  // Toyota Corolla قد بدأ تشغيل المحرك!

Sep 26, 2024
Read More