tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code05:32

JavaScript CONSTRUCTORS in 5 minutes! 🛠

Bro Code ↗

From the creator

#JavaScript #tutorial #course // constructor = special method for defining the // properties and methods of objects function Car(make, model, year, color){ this.make = make, this.model = model, this.year = year, this.color = color, this.drive = function(){console.log(`You drive the ${this.model}`)} } const car1 = new Car("Ford", "Mustang", 2024, "red"); const car2 = new Car("Chevrolet", "Camaro", 2025, "blue"); const car3 = new Car("Dodge", "Charger", 2026, "silver"); car1.drive(); car2.drive(); car3.drive(); console.log(car1.make); console.log(car1.model); console.log(car1.year); console.log(car1.color); console.log(car2.make); console.log(car2.model); console.log(car2.year); console.log(car2.color); console.log(car3.make); console.log(car3.model); console.log(car3.year); console.log(car3.color);

Published 2023-11-16 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code