0

Classes

What is the use of JavaScript classes? I don't understand how they work.

10th Apr 2020, 7:32 AM
Heather
Heather - avatar
1 Respuesta
+ 2
You probably use them all the time. If you have an array like let x = []; x.push(4); // x is now [4] that array was made from the `Array` class. So somewhere someone wrote class Array { push (value) { ... } ... } And you made a `new Array();` of which `[]` is a shorthand. Classes are like blueprints and you can make many objects from it. Classes are eeeeverywhere in programming. If the concept sounds too hard just keep programming, it will click eventually. Sololearn also has a couple of lessons on the topic. EDIT: Practical example: A poker game where you have a `Card` class, a `Player` class, a `Deck` class, a `Chip` class, etc. Classes give you a way of structuring larger code bases.
10th Apr 2020, 9:16 AM
Schindlabua
Schindlabua - avatar