declare variable class javascript 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);
Example 3: variables in js class
constructor(){
this.foo = bar
}