Premium Only Content
This video is only available to Rumble Premium subscribers. Subscribe to
enjoy exclusive content and ad-free viewing.
Learn JavaScript CLASSES in 6 minutes! 🏭
11 months ago
4
Automotive
Education
Programming
Coding
Software Development
Web Development
Mobile App Development
Computer Science
Coding Tutorial
Code Learning
Programming Language
// class = (ES6 feature) provides a more structured and cleaner way to
// work with objects compared to traditional constructor functions
// ex. static keyword, encapsulation, inheritance
class Product{
constructor(name, price){
this.name = name;
this.price = price;
}
displayProduct(){
console.log(`Product: ${this.name}`);
console.log(`Price: $${this.price.toFixed(2)}`);
}
calculateTotal(salesTax){
return this.price + (this.price * salesTax);
}
}
const salesTax = 0.05;
const product1 = new Product("Shirt", 19.99);
const product2 = new Product("Pants", 22.50);
const product3 = new Product("Underwear", 100.00);
product1.displayProduct();
const total = product1.calculateTotal(salesTax);
console.log(`Total price (with tax): $${total.toFixed(2)}`);
Loading comments...
-
1:11:24
LFA TV
12 hours agoENERGY WEDNESDAY: Markets Adjusting to Nuclear Threat | WORLD HD 11.20.24 @8am EST
12.6K3 -
1:13:23
Game On!
13 hours ago $1.79 earnedOregon IN, Colorado OUT! CFB Playoff Committee makes a statement with latest rankings!
19.9K3 -
1:00:54
PMG
1 day ago $3.50 earned"Biden just allowed Ukraine to Attack Russia!!"
12.5K3 -
15:52
Degenerate Jay
22 hours ago $19.19 earnedThe Joker 2 Cast Knew The Movie Was Bad?
71.1K21 -
3:01
MoneyMindsTrading
16 hours ago $9.69 earned#1 Day Trader on Rumble : NVIDIA EARNINGS 🚀
70.3K6 -
3:13:12
Price of Reason
18 hours agoDisney CEO Bob Iger PANICS after Trump win? Is Landman any good? The Game Awards Announces Nominees!
85K26 -
2:51:40
Jerry After Dark
18 hours ago3 Point Contest | Presented By Ghost Energy
161K6 -
2:24:56
Kim Iversen
16 hours agoRussia Threatens To NUKE Ukraine | RFK Jr Called Science’s True Voice By Former CDC Chief
140K331 -
1:16:12
Savanah Hernandez
14 hours agoCorrupt Democrats attempt to stop Trump’s plan to fix America
123K99 -
53:12
Glenn Greenwald
15 hours agoImprisoned For Journalism: Jeremy Loffredo On His Detention In Israel, Censorship & More | SYSTEM UPDATE #368
138K121