- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Classes
JavaScript Classes
JavaScript Classes
A JavaScript class is a template for creating objects that share the same shape.
Writing the same object by hand ten times is repetitive and easy to get wrong.
A class describes the shape once, and new builds as many as you need.
Example
Example
javascript
class Person {
constructor(name) {
this.name = name;
}
}
const ada = new Person("Ada");
console.log(ada.name);