javascript oop class variable code example
Example 1: javascript create class
class Car {
constructor(brand) {
this.carname = brand;
}
}
Example 2: javascript classes
class SayHelloTo {
name (to) {
console.log(`Hello ${to}`);
}
constructor (to) {
this.name(to);
}
}
const helloWorld = new SayHelloTo(World);