Learn JavaScript CLASSES in 6 minutes! 🏭

preview_player
Показать описание
// 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){
}

displayProduct(){
}

calculateTotal(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);

Рекомендации по теме
Комментарии
Автор

// 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 =
console.log(`Total price (with tax): $${total.toFixed(2)}`);

BroCodez
Автор

It's not everything you need to know about classes but the very basic.
Perfect Video. Thanks for sharing!

sevuszeld
Автор

cool, love the way you teach bro. quick easy and direct

ALLSTARDECOURO
Автор

Wow you just earned yourself a new follower i love the way you teach only by seeing how you showed this classes i can tell you are extremely good thanks a mil for teaching people out here

roseklaynk
Автор

Thank you for this instructional video. It was very helpful

Sijo
Автор

Short and clear, , thanks for the video

Adongo-cpun
Автор

very helpfull and easy to understand. thank u sirr

lilfrostgame
Автор

same thing i am doing since years, buti in my new folder structur i cant import the class.
How can i import the class ?

denniswi
Автор

can someone explains what is $ in JS? I'm trying to find but i just want a basic explanation

PointersHater
Автор

the deadpan "it's really good underwear guys" sent me

williamhu
Автор

am preparing for my oral IT exam right now THANK YOUU i did NOT pay attention when we learned about this and i need it lol

mayabakke
Автор

<*_> This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal. <_*>

piotrmazgaj
Автор

Buy why classes? don't we have functions? I am confused!!

ImHansana
Автор

Why do some codes have an underscore after "this."? Not in yours but I do see in some other examples on classes.

Tomouryu
Автор

bro can you teach us typeScript please

FuadTesfaye-eb
Автор

ya'll instead of learning static and constructor, just learn class. so you won't waste your time

Brakolli
Автор

hello when react (team) shar an update can u shar a vedios of it

mk
Автор

Hey Bro, I really appreciate your works but I got a question personally;
Why don’t you add a whitespace when you open a curly brackets? 😅

It’s always like this:
“class Product{}” instead of “class Product {}”

Also the comments 4 week ago but the video just published? I didn’t know you had membership for users.

neodevils
Автор

Bro how we can do ddos attack ?
In which video ?
How we can find the learning of ddos
What we need ?
Thanks bro

cocingtonxhanma
Автор

I'm the 1000th like
Before 999
After 1k🎉

mohamadfazil